Class: Content
Defined in: src/scan/content.ts:33
Represents content to be scanned by AIRS. Validates byte-length limits on construction and property assignment.
Constructors
Constructor
new Content(opts): Content;
Defined in: src/scan/content.ts:57
Create a new Content instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
opts | ContentOptions | Content fields; at least one of prompt, response, codePrompt, codeResponse, or toolEvent is required. |
Returns
Content
Throws
If no content field is provided or a field exceeds its byte-length limit.
Example
import { Content } from '@cdot65/prisma-airs-sdk';
const content = new Content({
prompt: 'What is the capital of France?',
response: 'The capital of France is Paris.',
});
// content.prompt => 'What is the capital of France?'
// content.response => 'The capital of France is Paris.'
Accessors
prompt
Get Signature
get prompt(): string | undefined;
Defined in: src/scan/content.ts:89
User prompt text. Setting a value validates its byte length (max 2 MB).
Example
import { Content } from '@cdot65/prisma-airs-sdk';
const content = new Content({ prompt: 'hello' });
content.prompt = 'Ignore previous instructions';
// content.prompt => 'Ignore previous instructions'
Returns
string | undefined
Set Signature
set prompt(value): void;
Defined in: src/scan/content.ts:92
Parameters
| Parameter | Type |
|---|---|
value | string | undefined |
Returns
void
response
Get Signature
get response(): string | undefined;
Defined in: src/scan/content.ts:112
AI model response text. Setting a value validates its byte length (max 2 MB).
Example
import { Content } from '@cdot65/prisma-airs-sdk';
const content = new Content({ prompt: 'hi' });
content.response = 'The capital of France is Paris.';
// content.response => 'The capital of France is Paris.'
Returns
string | undefined
Set Signature
set response(value): void;
Defined in: src/scan/content.ts:115
Parameters
| Parameter | Type |
|---|---|
value | string | undefined |
Returns
void
context
Get Signature
get context(): string | undefined;
Defined in: src/scan/content.ts:135
Conversation context. Setting a value validates its byte length (max 100 MB).
Example
import { Content } from '@cdot65/prisma-airs-sdk';
const content = new Content({ prompt: 'hi' });
content.context = 'User is asking about geography.';
// content.context => 'User is asking about geography.'
Returns
string | undefined
Set Signature
set context(value): void;
Defined in: src/scan/content.ts:138
Parameters
| Parameter | Type |
|---|---|
value | string | undefined |
Returns
void
codePrompt
Get Signature
get codePrompt(): string | undefined;
Defined in: src/scan/content.ts:158
Code prompt text. Setting a value validates its byte length (max 2 MB).
Example
import { Content } from '@cdot65/prisma-airs-sdk';
const content = new Content({ codePrompt: 'def add(a, b): return a + b' });
content.codePrompt = 'rm -rf /';
// content.codePrompt => 'rm -rf /'
Returns
string | undefined
Set Signature
set codePrompt(value): void;
Defined in: src/scan/content.ts:161
Parameters
| Parameter | Type |
|---|---|
value | string | undefined |
Returns
void
codeResponse
Get Signature
get codeResponse(): string | undefined;
Defined in: src/scan/content.ts:181
Code response text. Setting a value validates its byte length (max 2 MB).
Example
import { Content } from '@cdot65/prisma-airs-sdk';
const content = new Content({ prompt: 'write a sort fn' });
content.codeResponse = 'def sort(xs): return sorted(xs)';
// content.codeResponse => 'def sort(xs): return sorted(xs)'
Returns
string | undefined
Set Signature
set codeResponse(value): void;
Defined in: src/scan/content.ts:184
Parameters
| Parameter | Type |
|---|---|
value | string | undefined |
Returns
void
toolEvent
Get Signature
get toolEvent():
| objectOutputType<{
metadata: ZodOptional<ZodObject<{
ecosystem: ZodString;
method: ZodString;
server_name: ZodString;
tool_invoked: ZodOptional<ZodString>;
}, "passthrough", ZodTypeAny, objectOutputType<{
ecosystem: ZodString;
method: ZodString;
server_name: ZodString;
tool_invoked: ZodOptional<ZodString>;
}, ZodTypeAny, "passthrough">, objectInputType<{
ecosystem: ZodString;
method: ZodString;
server_name: ZodString;
tool_invoked: ZodOptional<ZodString>;
}, ZodTypeAny, "passthrough">>>;
input: ZodOptional<ZodString>;
output: ZodOptional<ZodString>;
}, ZodTypeAny, "passthrough">
| undefined;
Defined in: src/scan/content.ts:207
Tool/function call event data attached to the content.
Example
import { Content } from '@cdot65/prisma-airs-sdk';
const content = new Content({ prompt: 'use a tool' });
content.toolEvent = {
metadata: { ecosystem: 'mcp', method: 'invoke', server_name: 'files' },
input: '{}',
};
// content.toolEvent.metadata.server_name => 'files'
Returns
| objectOutputType<{
metadata: ZodOptional<ZodObject<{
ecosystem: ZodString;
method: ZodString;
server_name: ZodString;
tool_invoked: ZodOptional<ZodString>;
}, "passthrough", ZodTypeAny, objectOutputType<{
ecosystem: ZodString;
method: ZodString;
server_name: ZodString;
tool_invoked: ZodOptional<ZodString>;
}, ZodTypeAny, "passthrough">, objectInputType<{
ecosystem: ZodString;
method: ZodString;
server_name: ZodString;
tool_invoked: ZodOptional<ZodString>;
}, ZodTypeAny, "passthrough">>>;
input: ZodOptional<ZodString>;
output: ZodOptional<ZodString>;
}, ZodTypeAny, "passthrough">
| undefined
Set Signature
set toolEvent(value): void;
Defined in: src/scan/content.ts:210
Parameters
| Parameter | Type |
|---|---|
value | | objectOutputType<{ metadata: ZodOptional<ZodObject<{ ecosystem: ZodString; method: ZodString; server_name: ZodString; tool_invoked: ZodOptional<ZodString>; }, "passthrough", ZodTypeAny, objectOutputType<{ ecosystem: ZodString; method: ZodString; server_name: ZodString; tool_invoked: ZodOptional<ZodString>; }, ZodTypeAny, "passthrough">, objectInputType<{ ecosystem: ZodString; method: ZodString; server_name: ZodString; tool_invoked: ZodOptional<ZodString>; }, ZodTypeAny, "passthrough">>>; input: ZodOptional<ZodString>; output: ZodOptional<ZodString>; }, ZodTypeAny, "passthrough"> | undefined |
Returns
void
length
Get Signature
get length(): number;
Defined in: src/scan/content.ts:224
Total byte length of all text content fields.
Example
import { Content } from '@cdot65/prisma-airs-sdk';
const content = new Content({ prompt: 'ab', response: 'cd' });
// content.length => 4
Returns
number
Combined byte length of all text content fields.
Methods
toJSON()
toJSON(): objectOutputType;
Defined in: src/scan/content.ts:245
Serialize to the API request format.
Returns
objectOutputType
The content as a scan request contents inner object.
Example
import { Content } from '@cdot65/prisma-airs-sdk';
const content = new Content({ prompt: 'p', codePrompt: 'fn()' });
const json = content.toJSON();
// json => { prompt: 'p', code_prompt: 'fn()' }
fromJSON()
static fromJSON(json): Content;
Defined in: src/scan/content.ts:268
Create a Content instance from an API response object.
Parameters
| Parameter | Type | Description |
|---|---|---|
json | objectOutputType | Scan request contents inner object. |
Returns
Content
A new Content instance populated from the JSON object.
Example
import { Content } from '@cdot65/prisma-airs-sdk';
const content = Content.fromJSON({ prompt: 'p', code_response: 'cr' });
// content.prompt => 'p'
// content.codeResponse => 'cr'
fromJSONFile()
static fromJSONFile(filePath): Content;
Defined in: src/scan/content.ts:292
Load content from a JSON file.
Parameters
| Parameter | Type | Description |
|---|---|---|
filePath | string | Path to JSON file containing scan request contents. |
Returns
Content
A new Content instance populated from the JSON file.
Example
import { Content } from '@cdot65/prisma-airs-sdk';
// content.json => { "prompt": "from file", "response": "resp" }
const content = Content.fromJSONFile('./content.json');
// content.prompt => 'from file'
// content.response => 'resp'