@mozaik-ai/core 2.4.4 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -119,13 +119,14 @@ declare class Reasoning extends ContextItem {
119
119
  toJSON(): any;
120
120
  }
121
121
 
122
- declare abstract class Capability {
123
- abstract readonly capability: string;
124
- }
125
-
126
- interface GenerativeModel<Id extends string> {
127
- readonly id: Id;
128
- readonly capabilities: Capability[];
122
+ type ModelSpecification = {
123
+ name: string;
124
+ supportReasoningEffort: boolean;
125
+ defaultReasoningEffort: string | undefined;
126
+ supportStreaming: boolean;
127
+ };
128
+ interface GenerativeModel {
129
+ readonly specification: ModelSpecification;
129
130
  }
130
131
 
131
132
  declare class FunctionCallOutput extends ContextItem {
@@ -147,11 +148,15 @@ interface ContextRepository {
147
148
  getByProjectId(projectId: string): Promise<Context[]>;
148
149
  }
149
150
 
151
+ interface ReasoningEffort<Effort extends string> {
152
+ setReasoningEffort(effort: Effort): void;
153
+ getReasoningEffort(): Effort;
154
+ }
155
+
150
156
  declare class InferenceRequest {
151
- readonly model: GenerativeModel<string>;
157
+ readonly model: GenerativeModel & ReasoningEffort<string>;
152
158
  readonly context: Context;
153
- providerRequest: Record<string, unknown>;
154
- constructor(model: GenerativeModel<string>, context: Context);
159
+ constructor(model: GenerativeModel & ReasoningEffort<string>, context: Context);
155
160
  }
156
161
 
157
162
  interface ModelRuntime {
@@ -166,9 +171,17 @@ declare class OpenAIResponses implements ModelRuntime {
166
171
  extractContextItems(response: any): ContextItem[];
167
172
  }
168
173
 
169
- declare class GPT54 implements GenerativeModel<"gpt-5.4"> {
170
- readonly id = "gpt-5.4";
171
- readonly capabilities: Capability[];
174
+ type OpenAIReasoningEffortType = "xhigh" | "high" | "medium" | "low" | "none";
175
+ declare class GPT54 implements GenerativeModel, ReasoningEffort<OpenAIReasoningEffortType> {
176
+ readonly specification: {
177
+ name: string;
178
+ supportReasoningEffort: boolean;
179
+ defaultReasoningEffort: OpenAIReasoningEffortType;
180
+ supportStreaming: boolean;
181
+ };
182
+ private readonly effort;
183
+ setReasoningEffort(effort: OpenAIReasoningEffortType): void;
184
+ getReasoningEffort(): OpenAIReasoningEffortType;
172
185
  }
173
186
  declare const gpt54: GPT54;
174
187
 
package/dist/index.d.ts CHANGED
@@ -119,13 +119,14 @@ declare class Reasoning extends ContextItem {
119
119
  toJSON(): any;
120
120
  }
121
121
 
122
- declare abstract class Capability {
123
- abstract readonly capability: string;
124
- }
125
-
126
- interface GenerativeModel<Id extends string> {
127
- readonly id: Id;
128
- readonly capabilities: Capability[];
122
+ type ModelSpecification = {
123
+ name: string;
124
+ supportReasoningEffort: boolean;
125
+ defaultReasoningEffort: string | undefined;
126
+ supportStreaming: boolean;
127
+ };
128
+ interface GenerativeModel {
129
+ readonly specification: ModelSpecification;
129
130
  }
130
131
 
131
132
  declare class FunctionCallOutput extends ContextItem {
@@ -147,11 +148,15 @@ interface ContextRepository {
147
148
  getByProjectId(projectId: string): Promise<Context[]>;
148
149
  }
149
150
 
151
+ interface ReasoningEffort<Effort extends string> {
152
+ setReasoningEffort(effort: Effort): void;
153
+ getReasoningEffort(): Effort;
154
+ }
155
+
150
156
  declare class InferenceRequest {
151
- readonly model: GenerativeModel<string>;
157
+ readonly model: GenerativeModel & ReasoningEffort<string>;
152
158
  readonly context: Context;
153
- providerRequest: Record<string, unknown>;
154
- constructor(model: GenerativeModel<string>, context: Context);
159
+ constructor(model: GenerativeModel & ReasoningEffort<string>, context: Context);
155
160
  }
156
161
 
157
162
  interface ModelRuntime {
@@ -166,9 +171,17 @@ declare class OpenAIResponses implements ModelRuntime {
166
171
  extractContextItems(response: any): ContextItem[];
167
172
  }
168
173
 
169
- declare class GPT54 implements GenerativeModel<"gpt-5.4"> {
170
- readonly id = "gpt-5.4";
171
- readonly capabilities: Capability[];
174
+ type OpenAIReasoningEffortType = "xhigh" | "high" | "medium" | "low" | "none";
175
+ declare class GPT54 implements GenerativeModel, ReasoningEffort<OpenAIReasoningEffortType> {
176
+ readonly specification: {
177
+ name: string;
178
+ supportReasoningEffort: boolean;
179
+ defaultReasoningEffort: OpenAIReasoningEffortType;
180
+ supportStreaming: boolean;
181
+ };
182
+ private readonly effort;
183
+ setReasoningEffort(effort: OpenAIReasoningEffortType): void;
184
+ getReasoningEffort(): OpenAIReasoningEffortType;
172
185
  }
173
186
  declare const gpt54: GPT54;
174
187
 
package/dist/index.js CHANGED
@@ -273,113 +273,6 @@ var FunctionCallOutput = class _FunctionCallOutput extends ContextItem {
273
273
  }
274
274
  };
275
275
 
276
- // src/core/context-engine/condition/condition.ts
277
- var BaseCondition = class {
278
- and(other) {
279
- return new AndCondition(this, other);
280
- }
281
- or(other) {
282
- return new OrCondition(this, other);
283
- }
284
- not() {
285
- return new NotCondition(this);
286
- }
287
- };
288
- var AndCondition = class extends BaseCondition {
289
- constructor(left, right) {
290
- super();
291
- this.left = left;
292
- this.right = right;
293
- }
294
- isSatisfiedBy(candidate) {
295
- return this.left.isSatisfiedBy(candidate) && this.right.isSatisfiedBy(candidate);
296
- }
297
- };
298
- var NotCondition = class extends BaseCondition {
299
- constructor(condition) {
300
- super();
301
- this.condition = condition;
302
- }
303
- isSatisfiedBy(candidate) {
304
- return !this.condition.isSatisfiedBy(candidate);
305
- }
306
- };
307
- var OrCondition = class extends BaseCondition {
308
- constructor(left, right) {
309
- super();
310
- this.left = left;
311
- this.right = right;
312
- }
313
- isSatisfiedBy(candidate) {
314
- return this.left.isSatisfiedBy(candidate) || this.right.isSatisfiedBy(candidate);
315
- }
316
- };
317
-
318
- // src/core/context-engine/rule/rule.ts
319
- var Rule = class {
320
- constructor({ when, then }) {
321
- this.condition = when;
322
- this.action = then;
323
- }
324
- apply(candidate) {
325
- if (this.condition.isSatisfiedBy(candidate)) {
326
- return this.action.apply(candidate);
327
- }
328
- return candidate;
329
- }
330
- };
331
-
332
- // src/core/generative-model/capabilities/capability.ts
333
- var Capability = class {
334
- };
335
-
336
- // src/core/generative-model/capabilities/reasoning-effort.ts
337
- var ReasoningEffort = class extends Capability {
338
- constructor(supportedEfforts, defaultEffort) {
339
- super();
340
- this.capability = "reasoning-effort";
341
- this.supportedEfforts = supportedEfforts;
342
- this.reasoningEffort = defaultEffort;
343
- }
344
- setReasoningEffort(effort) {
345
- if (!this.supportedEfforts.includes(effort)) {
346
- throw new Error(`Invalid reasoning effort: ${effort}`);
347
- }
348
- this.reasoningEffort = effort;
349
- }
350
- getReasoningEffort() {
351
- return this.reasoningEffort;
352
- }
353
- };
354
-
355
- // src/providers/openai/rules/reasoning-effort.ts
356
- var ReasoningEffortSupported = class extends BaseCondition {
357
- isSatisfiedBy(candidate) {
358
- return candidate.model.capabilities.some((capability) => capability instanceof ReasoningEffort);
359
- }
360
- };
361
- var SetReasoningEffort = class {
362
- apply(candidate) {
363
- const reasoningCapability = candidate.model.capabilities.find(
364
- (capability) => capability instanceof ReasoningEffort
365
- );
366
- if (reasoningCapability) {
367
- const providerRequest = candidate.providerRequest;
368
- candidate.providerRequest = {
369
- ...providerRequest,
370
- reasoning: {
371
- effort: reasoningCapability.getReasoningEffort()
372
- }
373
- };
374
- }
375
- return candidate;
376
- }
377
- };
378
- var reasoningEffortRule = new Rule({
379
- when: new ReasoningEffortSupported(),
380
- then: new SetReasoningEffort()
381
- });
382
-
383
276
  // src/providers/openai/runtime/openai-responses.ts
384
277
  var import_openai = __toESM(require("openai"));
385
278
  var OpenAIResponses = class {
@@ -388,12 +281,17 @@ var OpenAIResponses = class {
388
281
  }
389
282
  async infer(inferenceRequest) {
390
283
  const input = this.mapContextToRequest(inferenceRequest.context);
391
- reasoningEffortRule.apply(inferenceRequest);
392
- const response = await this.client.responses.create({
393
- model: inferenceRequest.model.id,
394
- input,
395
- ...inferenceRequest.providerRequest
396
- });
284
+ const specification = inferenceRequest.model.specification;
285
+ let request = {
286
+ model: specification.name,
287
+ input
288
+ };
289
+ if (specification.supportReasoningEffort) {
290
+ request.reasoning = {
291
+ effort: inferenceRequest.model.getReasoningEffort()
292
+ };
293
+ }
294
+ const response = await this.client.responses.create(request);
397
295
  return this.extractContextItems(response);
398
296
  }
399
297
  mapContextToRequest(context) {
@@ -415,14 +313,37 @@ var OpenAIResponses = class {
415
313
  };
416
314
 
417
315
  // src/providers/openai/models/gpt-5-4.ts
418
- var openaiReasoningEffort = new ReasoningEffort(
419
- ["xhigh", "high", "medium", "low", "none"],
420
- "none"
421
- );
316
+ var OpenAIReasoningEffort = class {
317
+ constructor(reasoningEffort) {
318
+ this.reasoningEffort = reasoningEffort;
319
+ }
320
+ setReasoningEffort(effort) {
321
+ this.reasoningEffort = effort;
322
+ }
323
+ getReasoningEffort() {
324
+ if (!this.reasoningEffort) {
325
+ throw new Error("Reasoning effort not supported");
326
+ }
327
+ return this.reasoningEffort;
328
+ }
329
+ };
422
330
  var GPT54 = class {
423
331
  constructor() {
424
- this.id = "gpt-5.4";
425
- this.capabilities = [openaiReasoningEffort];
332
+ this.specification = {
333
+ name: "gpt-5.4",
334
+ supportReasoningEffort: true,
335
+ defaultReasoningEffort: "none",
336
+ supportStreaming: true
337
+ };
338
+ this.effort = new OpenAIReasoningEffort(
339
+ this.specification.defaultReasoningEffort
340
+ );
341
+ }
342
+ setReasoningEffort(effort) {
343
+ this.effort.setReasoningEffort(effort);
344
+ }
345
+ getReasoningEffort() {
346
+ return this.effort.getReasoningEffort();
426
347
  }
427
348
  };
428
349
  var gpt54 = new GPT54();
@@ -432,7 +353,6 @@ var InferenceRequest = class {
432
353
  constructor(model, context) {
433
354
  this.model = model;
434
355
  this.context = context;
435
- this.providerRequest = {};
436
356
  }
437
357
  };
438
358
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/core/context-runtime/context.ts","../src/core/context-runtime/context-item.ts","../src/core/context-runtime/content.ts","../src/core/context-runtime/content/input-text.ts","../src/core/context-runtime/input/user-message.ts","../src/core/context-runtime/input/developer-message.ts","../src/core/context-runtime/content/output-text.ts","../src/core/context-runtime/output/model-message.ts","../src/core/context-runtime/output/function-call.ts","../src/core/context-runtime/output/reasoning.ts","../src/core/context-runtime/input/function-call-output.ts","../src/core/context-engine/condition/condition.ts","../src/core/context-engine/rule/rule.ts","../src/core/generative-model/capabilities/capability.ts","../src/core/generative-model/capabilities/reasoning-effort.ts","../src/providers/openai/rules/reasoning-effort.ts","../src/providers/openai/runtime/openai-responses.ts","../src/providers/openai/models/gpt-5-4.ts","../src/core/generative-model/inference-request.ts"],"sourcesContent":["import { Context } from \"@core/context-runtime/context\"\nimport { ContextItem } from \"@core/context-runtime/context-item\"\nimport { UserMessage } from \"@core/context-runtime/input/user-message\"\nimport { DeveloperMessage } from \"@core/context-runtime/input/developer-message\"\nimport { ModelMessage } from \"@core/context-runtime/output/model-message\"\nimport { FunctionCall } from \"@core/context-runtime/output/function-call\"\nimport { Reasoning } from \"@core/context-runtime/output/reasoning\"\nimport { GenerativeModel } from \"@core/generative-model/generative-model\"\nimport { FunctionCallOutput } from \"@core/context-runtime/input/function-call-output\"\nimport { ContextRepository } from \"@core/context-runtime/context-repository\"\nimport { OpenAIResponses } from \"@openai/runtime/openai-responses\"\nimport { gpt54 } from \"@openai/models/gpt-5-4\"\nimport { InferenceRequest } from \"@core/generative-model/inference-request\"\n\nexport {\n\tContext,\n\tContextItem,\n\tUserMessage,\n\tDeveloperMessage,\n\tModelMessage,\n\tFunctionCall,\n\tFunctionCallOutput,\n\tReasoning,\n\tGenerativeModel,\n\tContextRepository,\n\tOpenAIResponses,\n\tgpt54,\n\tInferenceRequest,\n}\n","import { ContextItem } from \"@core/context-runtime/context-item\"\n\nexport class Context {\n\treadonly id: string\n\treadonly projectId: string\n\treadonly items: ContextItem[]\n\n\tconstructor(id: string, projectId: string, items: ContextItem[]) {\n\t\tthis.projectId = projectId\n\t\tthis.id = id\n\t\tthis.items = items\n\t}\n\n\taddItem(item: ContextItem): Context {\n\t\tthis.items.push(item)\n\t\treturn this\n\t}\n\n\tapplyModelOutput(items: ContextItem[]): Context {\n\t\tfor (const item of items) {\n\t\t\tconst itemType = item.getType()\n\t\t\tif (itemType !== \"function_call\" && itemType !== \"message\" && itemType !== \"reasoning\") {\n\t\t\t\tthrow new Error(`Invalid item type: ${itemType}`)\n\t\t\t}\n\t\t}\n\t\tthis.items.push(...items)\n\t\treturn this\n\t}\n\n\tgetItems(): ContextItem[] {\n\t\treturn this.items\n\t}\n\n\tstatic create(projectId: string): Context {\n\t\tconst id = crypto.randomUUID()\n\t\treturn new Context(id, projectId, [])\n\t}\n\n\tstatic rehydrate(data: { id: string; projectId: string; items: ContextItem[] }): Context {\n\t\treturn new Context(data.id, data.projectId, data.items)\n\t}\n\n\ttoJSON(): any {\n\t\treturn this.items.map((item) => item.toJSON())\n\t}\n}\n","export abstract class ContextItem {\n\tabstract readonly type: string\n\n\tgetType(): string {\n\t\treturn this.type\n\t}\n\n\tabstract toJSON(): any\n}\n","export abstract class Content {\n\tabstract readonly type: string\n}\n","import { Content } from \"@core/context-runtime/content\"\n\nexport class InputText extends Content {\n\treadonly type = \"input_text\"\n\n\tprivate constructor(public readonly text: string) {\n\t\tsuper()\n\t}\n\n\tstatic create(text: string): InputText {\n\t\treturn new InputText(text)\n\t}\n\n\tstatic rehydrate(data: { text: string }): InputText {\n\t\treturn new InputText(data.text)\n\t}\n\n\ttoJSON(): any[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\ttype: this.type,\n\t\t\t\ttext: this.text,\n\t\t\t},\n\t\t]\n\t}\n}\n","import { ContextItem } from \"@core/context-runtime/context-item\"\nimport { InputText } from \"@core/context-runtime/content/input-text\"\n\nexport class UserMessage extends ContextItem {\n\treadonly type = \"message\"\n\treadonly role = \"user\"\n\treadonly content: InputText\n\n\tprivate constructor(content: InputText) {\n\t\tsuper()\n\t\tthis.content = content\n\t}\n\n\tstatic create(text: string): UserMessage {\n\t\tconst content = InputText.create(text)\n\t\treturn new UserMessage(content)\n\t}\n\n\tstatic rehydrate(data: { text: string }): UserMessage {\n\t\tconst content = InputText.rehydrate(data)\n\t\treturn new UserMessage(content)\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\trole: this.role,\n\t\t\tcontent: this.content.toJSON(),\n\t\t}\n\t}\n}\n","import { InputText } from \"@core/context-runtime/content/input-text\"\nimport { ContextItem } from \"@core/context-runtime/context-item\"\n\nexport class DeveloperMessage extends ContextItem {\n\treadonly type = \"message\"\n\treadonly role = \"developer\"\n\treadonly content: InputText\n\n\tprivate constructor(content: InputText) {\n\t\tsuper()\n\t\tthis.content = content\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\trole: this.role,\n\t\t\tcontent: this.content.toJSON(),\n\t\t}\n\t}\n\n\tstatic create(text: string): DeveloperMessage {\n\t\tconst content = InputText.create(text)\n\t\treturn new DeveloperMessage(content)\n\t}\n\n\tstatic rehydrate(data: { text: string }): DeveloperMessage {\n\t\tconst content = InputText.rehydrate(data)\n\t\treturn new DeveloperMessage(content)\n\t}\n}\n","import { Content } from \"@core/context-runtime/content\"\n\nexport class OutputText extends Content {\n\treadonly type = \"output_text\"\n\n\tprivate constructor(public readonly text: string) {\n\t\tsuper()\n\t}\n\n\tstatic rehydrate(data: { text: string }): OutputText {\n\t\treturn new OutputText(data.text)\n\t}\n\n\ttoJSON(): any[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\ttype: this.type,\n\t\t\t\ttext: this.text,\n\t\t\t},\n\t\t]\n\t}\n}\n","import { ContextItem } from \"@core/context-runtime/context-item\"\nimport { OutputText } from \"@core/context-runtime/content/output-text\"\n\nexport class ModelMessage extends ContextItem {\n\treadonly type = \"message\"\n\treadonly role = \"assistant\"\n\treadonly content: OutputText\n\n\tprivate constructor(content: OutputText) {\n\t\tsuper()\n\t\tthis.content = content\n\t}\n\n\tstatic rehydrate(data: { text: string }): ModelMessage {\n\t\tconst content = OutputText.rehydrate(data)\n\t\treturn new ModelMessage(content)\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\trole: this.role,\n\t\t\tcontent: this.content.toJSON(),\n\t\t}\n\t}\n}\n","import { ContextItem } from \"@core/context-runtime/context-item\"\n\nexport class FunctionCall extends ContextItem {\n\treadonly type = \"function_call\"\n\treadonly callId: string\n\treadonly name: string\n\treadonly args: string\n\n\tprivate constructor(callId: string, name: string, args: string) {\n\t\tsuper()\n\t\tthis.callId = callId\n\t\tthis.name = name\n\t\tthis.args = args\n\t}\n\n\tstatic rehydrate(data: { callId: string; name: string; args: string }): FunctionCall {\n\t\treturn new FunctionCall(data.callId, data.name, data.args)\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\tcallId: this.callId,\n\t\t\tname: this.name,\n\t\t\targuments: this.args,\n\t\t}\n\t}\n}\n","import { InputText } from \"@core/context-runtime/content/input-text\"\nimport { SummaryText } from \"@core/context-runtime/content/summary-text\"\nimport { ContextItem } from \"@core/context-runtime/context-item\"\n\nexport class Reasoning extends ContextItem {\n\treadonly type = \"reasoning\"\n\treadonly content: InputText | undefined\n\treadonly encryptedContent: string | undefined\n\treadonly summary: SummaryText[]\n\n\tprivate constructor(\n\t\tcontent: InputText | undefined,\n\t\tencryptedContent?: string | undefined,\n\t\tsummary: SummaryText[] = [],\n\t) {\n\t\tsuper()\n\t\tthis.content = content\n\t\tthis.encryptedContent = encryptedContent\n\t\tthis.summary = summary\n\t}\n\n\tstatic rehydrate(data: {\n\t\tcontent: InputText | undefined\n\t\tencryptedContent: string | undefined\n\t\tsummary: SummaryText[]\n\t}): Reasoning {\n\t\treturn new Reasoning(data.content, data.encryptedContent, data.summary)\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\tcontent: this.content?.toJSON(),\n\t\t\tencryptedContent: this.encryptedContent,\n\t\t\tsummary: this.summary.map((s) => s.toJSON()),\n\t\t}\n\t}\n}\n","import { ContextItem } from \"@core/context-runtime/context-item\"\nimport { InputText } from \"@core/context-runtime/content/input-text\"\n\nexport class FunctionCallOutput extends ContextItem {\n\treadonly type = \"function_call_output\"\n\treadonly callId: string\n\treadonly output: InputText[]\n\n\tprivate constructor(callId: string, output: InputText[]) {\n\t\tsuper()\n\t\tthis.callId = callId\n\t\tthis.output = output\n\t}\n\n\tstatic create(callId: string, output: InputText[]): FunctionCallOutput {\n\t\treturn new FunctionCallOutput(callId, output)\n\t}\n\n\tstatic rehydrate(data: { callId: string; output: InputText[] }): FunctionCallOutput {\n\t\treturn new FunctionCallOutput(data.callId, data.output)\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\tcallId: this.callId,\n\t\t\toutput: this.output.map((o) => o.toJSON()),\n\t\t}\n\t}\n}\n","export interface Condition<T> {\n\tisSatisfiedBy(candidate: T): boolean\n\tand(other: Condition<T>): Condition<T>\n\tor(other: Condition<T>): Condition<T>\n\tnot(): Condition<T>\n}\n\nexport abstract class BaseCondition<T> implements Condition<T> {\n\tabstract isSatisfiedBy(candidate: T): boolean\n\n\tand(other: Condition<T>): Condition<T> {\n\t\treturn new AndCondition(this, other)\n\t}\n\n\tor(other: Condition<T>): Condition<T> {\n\t\treturn new OrCondition(this, other)\n\t}\n\n\tnot(): Condition<T> {\n\t\treturn new NotCondition(this)\n\t}\n}\n\nexport class AndCondition<T> extends BaseCondition<T> {\n\tconstructor(\n\t\tprivate readonly left: Condition<T>,\n\t\tprivate readonly right: Condition<T>,\n\t) {\n\t\tsuper()\n\t}\n\n\tisSatisfiedBy(candidate: T): boolean {\n\t\treturn this.left.isSatisfiedBy(candidate) && this.right.isSatisfiedBy(candidate)\n\t}\n}\n\nexport class NotCondition<T> extends BaseCondition<T> {\n\tconstructor(private readonly condition: Condition<T>) {\n\t\tsuper()\n\t}\n\n\tisSatisfiedBy(candidate: T): boolean {\n\t\treturn !this.condition.isSatisfiedBy(candidate)\n\t}\n}\n\nexport class OrCondition<T> extends BaseCondition<T> {\n\tconstructor(\n\t\tprivate readonly left: Condition<T>,\n\t\tprivate readonly right: Condition<T>,\n\t) {\n\t\tsuper()\n\t}\n\n\tisSatisfiedBy(candidate: T): boolean {\n\t\treturn this.left.isSatisfiedBy(candidate) || this.right.isSatisfiedBy(candidate)\n\t}\n}\n","import { Condition } from \"@core/context-engine/condition/condition\"\n\nexport interface Action<T> {\n\tapply(candidate: T): T\n}\n\nexport class Rule<T> {\n\tprivate condition: Condition<T>\n\tprivate action: Action<T>\n\n\tconstructor({ when, then }: { when: Condition<T>; then: Action<T> }) {\n\t\tthis.condition = when\t\n\t\tthis.action = then\n\t}\n\n\tapply(candidate: T): T {\n\t\tif (this.condition.isSatisfiedBy(candidate)) {\n\t\t\treturn this.action.apply(candidate)\n\t\t}\n\t\treturn candidate\n\t}\n}\n","export abstract class Capability {\n abstract readonly capability: string\n}","import { Capability } from \"./capability\"\n\nexport class ReasoningEffort<Effort extends string> extends Capability {\n\treadonly capability = \"reasoning-effort\"\n\treadonly supportedEfforts: readonly Effort[]\n\treasoningEffort: Effort\n\n\tconstructor(supportedEfforts: readonly Effort[], defaultEffort: Effort) {\n\t\tsuper()\n\t\tthis.supportedEfforts = supportedEfforts\n\t\tthis.reasoningEffort = defaultEffort\n\t}\n\n\tsetReasoningEffort(effort: Effort): void {\n\t\tif (!this.supportedEfforts.includes(effort)) {\n\t\t\tthrow new Error(`Invalid reasoning effort: ${effort}`)\n\t\t}\n\t\tthis.reasoningEffort = effort;\n\t}\n\n\tgetReasoningEffort(): Effort {\n\t\treturn this.reasoningEffort\n\t}\n}\n","import { BaseCondition } from \"@core/context-engine/condition/condition\"\nimport { Action, Rule } from \"@core/context-engine/rule/rule\"\nimport { ReasoningEffort } from \"@core/generative-model/capabilities/reasoning-effort\"\nimport { InferenceRequest } from \"@core/generative-model/inference-request\"\n\nexport class ReasoningEffortSupported extends BaseCondition<InferenceRequest> {\n\tisSatisfiedBy(candidate: InferenceRequest): boolean {\n\t\treturn candidate.model.capabilities.some((capability) => capability instanceof ReasoningEffort)\n\t}\n}\n\nexport class SetReasoningEffort implements Action<InferenceRequest> {\n\tapply(candidate: InferenceRequest): InferenceRequest {\n\t\tconst reasoningCapability = candidate.model.capabilities.find(\n\t\t\t(capability) => capability instanceof ReasoningEffort,\n\t\t)\n\t\tif (reasoningCapability) {\n\t\t\tconst providerRequest = candidate.providerRequest\n\t\t\tcandidate.providerRequest = {\n\t\t\t\t...providerRequest,\n\t\t\t\treasoning: {\n\t\t\t\t\teffort: reasoningCapability.getReasoningEffort(),\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\t\treturn candidate\n\t}\n}\nexport const reasoningEffortRule = new Rule({\n\twhen: new ReasoningEffortSupported(),\n\tthen: new SetReasoningEffort(),\n})\n","import { Context } from \"@core/context-runtime/context\"\nimport { ContextItem } from \"@core/context-runtime/context-item\"\nimport { FunctionCall } from \"@core/context-runtime/output/function-call\"\nimport { ModelMessage } from \"@core/context-runtime/output/model-message\"\nimport { Reasoning } from \"@core/context-runtime/output/reasoning\"\nimport { InferenceRequest } from \"@core/generative-model/inference-request\"\nimport { ModelRuntime } from \"@core/generative-model/runtime/model-runtime\"\nimport { reasoningEffortRule } from \"@openai/rules/reasoning-effort\"\nimport OpenAI from \"openai\"\n\nexport class OpenAIResponses implements ModelRuntime {\n\tprivate readonly client: OpenAI\n\n\tconstructor() {\n\t\tthis.client = new OpenAI()\n\t}\n\n\tasync infer(inferenceRequest: InferenceRequest): Promise<ContextItem[]> {\n\t\tconst input = this.mapContextToRequest(inferenceRequest.context)\n\n\t\treasoningEffortRule.apply(inferenceRequest)\n\n\t\tconst response = await this.client.responses.create({\n\t\t\tmodel: inferenceRequest.model.id,\n\t\t\tinput: input,\n\t\t\t...inferenceRequest.providerRequest,\n\t\t})\n\n\t\treturn this.extractContextItems(response)\n\t}\n\n\tmapContextToRequest(context: Context): any[] {\n\t\treturn context.getItems().map((item) => item.toJSON())\n\t}\n\n\textractContextItems(response: any): ContextItem[] {\n\t\treturn response.output.map((item: any) => {\n\t\t\tif (item.type === \"message\" && item.status === \"completed\") {\n\t\t\t\treturn ModelMessage.rehydrate(item.content[0] as { text: string })\n\t\t\t}\n\t\t\tif (item.type === \"function_call\" && item.status === \"completed\") {\n\t\t\t\treturn FunctionCall.rehydrate(item)\n\t\t\t}\n\t\t\tif (item.type === \"reasoning\") {\n\t\t\t\treturn Reasoning.rehydrate(item)\n\t\t\t}\n\t\t})\n\t}\n}\n","import { Capability } from \"@core/generative-model/capabilities/capability\"\nimport { ReasoningEffort } from \"@core/generative-model/capabilities/reasoning-effort\"\nimport { GenerativeModel } from \"@core/generative-model/generative-model\"\n\nexport const openaiReasoningEffort = new ReasoningEffort<\"xhigh\" | \"high\" | \"medium\" | \"low\" | \"none\">(\n\t[\"xhigh\", \"high\", \"medium\", \"low\", \"none\"],\n\t\"none\",\n)\n\nexport class GPT54 implements GenerativeModel<\"gpt-5.4\"> {\n\treadonly id = \"gpt-5.4\"\n\treadonly capabilities: Capability[] = [openaiReasoningEffort]\n}\n\nexport const gpt54 = new GPT54()\n","import { Context } from \"@core/context-runtime/context\"\nimport { GenerativeModel } from \"./generative-model\"\n\nexport class InferenceRequest {\n\treadonly model: GenerativeModel<string>\n\treadonly context: Context\n providerRequest: Record<string, unknown>\n\n\tconstructor(model: GenerativeModel<string>, context: Context) {\n\t\tthis.model = model\n\t\tthis.context = context\n\t\tthis.providerRequest = {}\n\t}\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,UAAN,MAAM,SAAQ;AAAA,EAKpB,YAAY,IAAY,WAAmB,OAAsB;AAChE,SAAK,YAAY;AACjB,SAAK,KAAK;AACV,SAAK,QAAQ;AAAA,EACd;AAAA,EAEA,QAAQ,MAA4B;AACnC,SAAK,MAAM,KAAK,IAA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C,CAAC,SAAS,QAAQ,UAAU,OAAO,MAAM;AAAA,EACzC;AACD;AAEO,IAAM,QAAN,MAAkD;AAAA,EAAlD;AACN,SAAS,KAAK;AACd,SAAS,eAA6B,CAAC,qBAAqB;AAAA;AAC7D;AAEO,IAAM,QAAQ,IAAI,MAAM;;;ACXxB,IAAM,mBAAN,MAAuB;AAAA,EAK7B,YAAY,OAAgC,SAAkB;AAC7D,SAAK,QAAQ;AACb,SAAK,UAAU;AACf,SAAK,kBAAkB,CAAC;AAAA,EACzB;AACD;","names":["OpenAI"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/core/context-runtime/context.ts","../src/core/context-runtime/context-item.ts","../src/core/context-runtime/content.ts","../src/core/context-runtime/content/input-text.ts","../src/core/context-runtime/input/user-message.ts","../src/core/context-runtime/input/developer-message.ts","../src/core/context-runtime/content/output-text.ts","../src/core/context-runtime/output/model-message.ts","../src/core/context-runtime/output/function-call.ts","../src/core/context-runtime/output/reasoning.ts","../src/core/context-runtime/input/function-call-output.ts","../src/providers/openai/runtime/openai-responses.ts","../src/providers/openai/models/gpt-5-4.ts","../src/core/generative-model/inference-request.ts"],"sourcesContent":["import { Context } from \"@core/context-runtime/context\"\nimport { ContextItem } from \"@core/context-runtime/context-item\"\nimport { UserMessage } from \"@core/context-runtime/input/user-message\"\nimport { DeveloperMessage } from \"@core/context-runtime/input/developer-message\"\nimport { ModelMessage } from \"@core/context-runtime/output/model-message\"\nimport { FunctionCall } from \"@core/context-runtime/output/function-call\"\nimport { Reasoning } from \"@core/context-runtime/output/reasoning\"\nimport { GenerativeModel } from \"@core/generative-model/generative-model\"\nimport { FunctionCallOutput } from \"@core/context-runtime/input/function-call-output\"\nimport { ContextRepository } from \"@core/context-runtime/context-repository\"\nimport { OpenAIResponses } from \"@openai/runtime/openai-responses\"\nimport { gpt54 } from \"@openai/models/gpt-5-4\"\nimport { InferenceRequest } from \"@core/generative-model/inference-request\"\n\nexport {\n\tContext,\n\tContextItem,\n\tUserMessage,\n\tDeveloperMessage,\n\tModelMessage,\n\tFunctionCall,\n\tFunctionCallOutput,\n\tReasoning,\n\tGenerativeModel,\n\tContextRepository,\n\tOpenAIResponses,\n\tgpt54,\n\tInferenceRequest,\n}\n","import { ContextItem } from \"@core/context-runtime/context-item\"\n\nexport class Context {\n\treadonly id: string\n\treadonly projectId: string\n\treadonly items: ContextItem[]\n\n\tconstructor(id: string, projectId: string, items: ContextItem[]) {\n\t\tthis.projectId = projectId\n\t\tthis.id = id\n\t\tthis.items = items\n\t}\n\n\taddItem(item: ContextItem): Context {\n\t\tthis.items.push(item)\n\t\treturn this\n\t}\n\n\tapplyModelOutput(items: ContextItem[]): Context {\n\t\tfor (const item of items) {\n\t\t\tconst itemType = item.getType()\n\t\t\tif (itemType !== \"function_call\" && itemType !== \"message\" && itemType !== \"reasoning\") {\n\t\t\t\tthrow new Error(`Invalid item type: ${itemType}`)\n\t\t\t}\n\t\t}\n\t\tthis.items.push(...items)\n\t\treturn this\n\t}\n\n\tgetItems(): ContextItem[] {\n\t\treturn this.items\n\t}\n\n\tstatic create(projectId: string): Context {\n\t\tconst id = crypto.randomUUID()\n\t\treturn new Context(id, projectId, [])\n\t}\n\n\tstatic rehydrate(data: { id: string; projectId: string; items: ContextItem[] }): Context {\n\t\treturn new Context(data.id, data.projectId, data.items)\n\t}\n\n\ttoJSON(): any {\n\t\treturn this.items.map((item) => item.toJSON())\n\t}\n}\n","export abstract class ContextItem {\n\tabstract readonly type: string\n\n\tgetType(): string {\n\t\treturn this.type\n\t}\n\n\tabstract toJSON(): any\n}\n","export abstract class Content {\n\tabstract readonly type: string\n}\n","import { Content } from \"@core/context-runtime/content\"\n\nexport class InputText extends Content {\n\treadonly type = \"input_text\"\n\n\tprivate constructor(public readonly text: string) {\n\t\tsuper()\n\t}\n\n\tstatic create(text: string): InputText {\n\t\treturn new InputText(text)\n\t}\n\n\tstatic rehydrate(data: { text: string }): InputText {\n\t\treturn new InputText(data.text)\n\t}\n\n\ttoJSON(): any[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\ttype: this.type,\n\t\t\t\ttext: this.text,\n\t\t\t},\n\t\t]\n\t}\n}\n","import { ContextItem } from \"@core/context-runtime/context-item\"\nimport { InputText } from \"@core/context-runtime/content/input-text\"\n\nexport class UserMessage extends ContextItem {\n\treadonly type = \"message\"\n\treadonly role = \"user\"\n\treadonly content: InputText\n\n\tprivate constructor(content: InputText) {\n\t\tsuper()\n\t\tthis.content = content\n\t}\n\n\tstatic create(text: string): UserMessage {\n\t\tconst content = InputText.create(text)\n\t\treturn new UserMessage(content)\n\t}\n\n\tstatic rehydrate(data: { text: string }): UserMessage {\n\t\tconst content = InputText.rehydrate(data)\n\t\treturn new UserMessage(content)\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\trole: this.role,\n\t\t\tcontent: this.content.toJSON(),\n\t\t}\n\t}\n}\n","import { InputText } from \"@core/context-runtime/content/input-text\"\nimport { ContextItem } from \"@core/context-runtime/context-item\"\n\nexport class DeveloperMessage extends ContextItem {\n\treadonly type = \"message\"\n\treadonly role = \"developer\"\n\treadonly content: InputText\n\n\tprivate constructor(content: InputText) {\n\t\tsuper()\n\t\tthis.content = content\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\trole: this.role,\n\t\t\tcontent: this.content.toJSON(),\n\t\t}\n\t}\n\n\tstatic create(text: string): DeveloperMessage {\n\t\tconst content = InputText.create(text)\n\t\treturn new DeveloperMessage(content)\n\t}\n\n\tstatic rehydrate(data: { text: string }): DeveloperMessage {\n\t\tconst content = InputText.rehydrate(data)\n\t\treturn new DeveloperMessage(content)\n\t}\n}\n","import { Content } from \"@core/context-runtime/content\"\n\nexport class OutputText extends Content {\n\treadonly type = \"output_text\"\n\n\tprivate constructor(public readonly text: string) {\n\t\tsuper()\n\t}\n\n\tstatic rehydrate(data: { text: string }): OutputText {\n\t\treturn new OutputText(data.text)\n\t}\n\n\ttoJSON(): any[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\ttype: this.type,\n\t\t\t\ttext: this.text,\n\t\t\t},\n\t\t]\n\t}\n}\n","import { ContextItem } from \"@core/context-runtime/context-item\"\nimport { OutputText } from \"@core/context-runtime/content/output-text\"\n\nexport class ModelMessage extends ContextItem {\n\treadonly type = \"message\"\n\treadonly role = \"assistant\"\n\treadonly content: OutputText\n\n\tprivate constructor(content: OutputText) {\n\t\tsuper()\n\t\tthis.content = content\n\t}\n\n\tstatic rehydrate(data: { text: string }): ModelMessage {\n\t\tconst content = OutputText.rehydrate(data)\n\t\treturn new ModelMessage(content)\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\trole: this.role,\n\t\t\tcontent: this.content.toJSON(),\n\t\t}\n\t}\n}\n","import { ContextItem } from \"@core/context-runtime/context-item\"\n\nexport class FunctionCall extends ContextItem {\n\treadonly type = \"function_call\"\n\treadonly callId: string\n\treadonly name: string\n\treadonly args: string\n\n\tprivate constructor(callId: string, name: string, args: string) {\n\t\tsuper()\n\t\tthis.callId = callId\n\t\tthis.name = name\n\t\tthis.args = args\n\t}\n\n\tstatic rehydrate(data: { callId: string; name: string; args: string }): FunctionCall {\n\t\treturn new FunctionCall(data.callId, data.name, data.args)\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\tcallId: this.callId,\n\t\t\tname: this.name,\n\t\t\targuments: this.args,\n\t\t}\n\t}\n}\n","import { InputText } from \"@core/context-runtime/content/input-text\"\nimport { SummaryText } from \"@core/context-runtime/content/summary-text\"\nimport { ContextItem } from \"@core/context-runtime/context-item\"\n\nexport class Reasoning extends ContextItem {\n\treadonly type = \"reasoning\"\n\treadonly content: InputText | undefined\n\treadonly encryptedContent: string | undefined\n\treadonly summary: SummaryText[]\n\n\tprivate constructor(\n\t\tcontent: InputText | undefined,\n\t\tencryptedContent?: string | undefined,\n\t\tsummary: SummaryText[] = [],\n\t) {\n\t\tsuper()\n\t\tthis.content = content\n\t\tthis.encryptedContent = encryptedContent\n\t\tthis.summary = summary\n\t}\n\n\tstatic rehydrate(data: {\n\t\tcontent: InputText | undefined\n\t\tencryptedContent: string | undefined\n\t\tsummary: SummaryText[]\n\t}): Reasoning {\n\t\treturn new Reasoning(data.content, data.encryptedContent, data.summary)\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\tcontent: this.content?.toJSON(),\n\t\t\tencryptedContent: this.encryptedContent,\n\t\t\tsummary: this.summary.map((s) => s.toJSON()),\n\t\t}\n\t}\n}\n","import { ContextItem } from \"@core/context-runtime/context-item\"\nimport { InputText } from \"@core/context-runtime/content/input-text\"\n\nexport class FunctionCallOutput extends ContextItem {\n\treadonly type = \"function_call_output\"\n\treadonly callId: string\n\treadonly output: InputText[]\n\n\tprivate constructor(callId: string, output: InputText[]) {\n\t\tsuper()\n\t\tthis.callId = callId\n\t\tthis.output = output\n\t}\n\n\tstatic create(callId: string, output: InputText[]): FunctionCallOutput {\n\t\treturn new FunctionCallOutput(callId, output)\n\t}\n\n\tstatic rehydrate(data: { callId: string; output: InputText[] }): FunctionCallOutput {\n\t\treturn new FunctionCallOutput(data.callId, data.output)\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\tcallId: this.callId,\n\t\t\toutput: this.output.map((o) => o.toJSON()),\n\t\t}\n\t}\n}\n","import { Context } from \"@core/context-runtime/context\"\nimport { ContextItem } from \"@core/context-runtime/context-item\"\nimport { FunctionCall } from \"@core/context-runtime/output/function-call\"\nimport { ModelMessage } from \"@core/context-runtime/output/model-message\"\nimport { Reasoning } from \"@core/context-runtime/output/reasoning\"\nimport { InferenceRequest } from \"@core/generative-model/inference-request\"\nimport { ModelRuntime } from \"@core/generative-model/runtime/model-runtime\"\nimport OpenAI from \"openai\"\n\nexport class OpenAIResponses implements ModelRuntime {\n\tprivate readonly client: OpenAI\n\tconstructor() {\n\t\tthis.client = new OpenAI()\n\t}\n\n\tasync infer(inferenceRequest: InferenceRequest): Promise<ContextItem[]> {\n\t\tconst input = this.mapContextToRequest(inferenceRequest.context)\n\n\t\tconst specification = inferenceRequest.model.specification\n\t\tlet request: any = {\n\t\t\tmodel: specification.name,\n\t\t\tinput: input,\n\t\t}\n\n\t\tif (specification.supportReasoningEffort) {\n\t\t\trequest.reasoning = {\n\t\t\t\teffort: inferenceRequest.model.getReasoningEffort(),\n\t\t\t}\n\t\t}\n\n\t\tconst response = await this.client.responses.create(request)\n\n\t\treturn this.extractContextItems(response)\n\t}\n\n\tmapContextToRequest(context: Context): any[] {\n\t\treturn context.getItems().map((item) => item.toJSON())\n\t}\n\n\textractContextItems(response: any): ContextItem[] {\n\t\treturn response.output.map((item: any) => {\n\t\t\tif (item.type === \"message\" && item.status === \"completed\") {\n\t\t\t\treturn ModelMessage.rehydrate(item.content[0] as { text: string })\n\t\t\t}\n\t\t\tif (item.type === \"function_call\" && item.status === \"completed\") {\n\t\t\t\treturn FunctionCall.rehydrate(item)\n\t\t\t}\n\t\t\tif (item.type === \"reasoning\") {\n\t\t\t\treturn Reasoning.rehydrate(item)\n\t\t\t}\n\t\t})\n\t}\n}\n","import { ReasoningEffort } from \"@core/generative-model/capabilities/reasoning-effort\"\nimport { GenerativeModel } from \"@core/generative-model/generative-model\"\n\nexport type OpenAIReasoningEffortType = \"xhigh\" | \"high\" | \"medium\" | \"low\" | \"none\"\n\nexport class OpenAIReasoningEffort implements ReasoningEffort<OpenAIReasoningEffortType> {\n\treasoningEffort: OpenAIReasoningEffortType\n\n\tconstructor(reasoningEffort: OpenAIReasoningEffortType) {\n\t\tthis.reasoningEffort = reasoningEffort\n\t}\n\n\tsetReasoningEffort(effort: OpenAIReasoningEffortType): void {\n\t\tthis.reasoningEffort = effort\n\t}\n\tgetReasoningEffort(): OpenAIReasoningEffortType {\n\t\tif (!this.reasoningEffort) {\n\t\t\tthrow new Error(\"Reasoning effort not supported\")\n\t\t}\n\t\treturn this.reasoningEffort\n\t}\n}\n\nexport class GPT54 implements GenerativeModel, ReasoningEffort<OpenAIReasoningEffortType> {\n\treadonly specification = {\n\t\tname: \"gpt-5.4\",\n\t\tsupportReasoningEffort: true,\n\t\tdefaultReasoningEffort: \"none\" as OpenAIReasoningEffortType,\n\t\tsupportStreaming: true,\n\t}\n\n\tprivate readonly effort: OpenAIReasoningEffort = new OpenAIReasoningEffort(\n\t\tthis.specification.defaultReasoningEffort,\n\t)\n\n\tsetReasoningEffort(effort: OpenAIReasoningEffortType): void {\n\t\tthis.effort.setReasoningEffort(effort)\n\t}\n\tgetReasoningEffort(): OpenAIReasoningEffortType {\n\t\treturn this.effort.getReasoningEffort()\n\t}\n}\n\nexport const gpt54: GPT54 = new GPT54()\n","import { Context } from \"@core/context-runtime/context\"\nimport { GenerativeModel } from \"./generative-model\"\nimport { ReasoningEffort } from \"./capabilities/reasoning-effort\"\n\nexport class InferenceRequest {\n\treadonly model: GenerativeModel & ReasoningEffort<string>\n\treadonly context: Context\n\n\tconstructor(model: GenerativeModel & ReasoningEffort<string>, context: Context) {\n\t\tthis.model = model\n\t\tthis.context = context\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,UAAN,MAAM,SAAQ;AAAA,EAKpB,YAAY,IAAY,WAAmB,OAAsB;AAChE,SAAK,YAAY;AACjB,SAAK,KAAK;AACV,SAAK,QAAQ;AAAA,EACd;AAAA,EAEA,QAAQ,MAA4B;AACnC,SAAK,MAAM,KAAK,IAAI;AACpB,WAAO;AAAA,EACR;AAAA,EAEA,iBAAiB,OAA+B;AAC/C,eAAW,QAAQ,OAAO;AACzB,YAAM,WAAW,KAAK,QAAQ;AAC9B,UAAI,aAAa,mBAAmB,aAAa,aAAa,aAAa,aAAa;AACvF,cAAM,IAAI,MAAM,sBAAsB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UAAU,KAAK,QAAQ,CAAC,CAAqB;AAAA,MAClE;AACA,UAAI,KAAK,SAAS,mBAAmB,KAAK,WAAW,aAAa;AACjE,eAAO,aAAa,UAAU,IAAI;AAAA,MACnC;AACA,UAAI,KAAK,SAAS,aAAa;AAC9B,eAAO,UAAU,UAAU,IAAI;AAAA,MAChC;AAAA,IACD,CAAC;AAAA,EACF;AACD;;;AC/CO,IAAM,wBAAN,MAAkF;AAAA,EAGxF,YAAY,iBAA4C;AACvD,SAAK,kBAAkB;AAAA,EACxB;AAAA,EAEA,mBAAmB,QAAyC;AAC3D,SAAK,kBAAkB;AAAA,EACxB;AAAA,EACA,qBAAgD;AAC/C,QAAI,CAAC,KAAK,iBAAiB;AAC1B,YAAM,IAAI,MAAM,gCAAgC;AAAA,IACjD;AACA,WAAO,KAAK;AAAA,EACb;AACD;AAEO,IAAM,QAAN,MAAmF;AAAA,EAAnF;AACN,SAAS,gBAAgB;AAAA,MACxB,MAAM;AAAA,MACN,wBAAwB;AAAA,MACxB,wBAAwB;AAAA,MACxB,kBAAkB;AAAA,IACnB;AAEA,SAAiB,SAAgC,IAAI;AAAA,MACpD,KAAK,cAAc;AAAA,IACpB;AAAA;AAAA,EAEA,mBAAmB,QAAyC;AAC3D,SAAK,OAAO,mBAAmB,MAAM;AAAA,EACtC;AAAA,EACA,qBAAgD;AAC/C,WAAO,KAAK,OAAO,mBAAmB;AAAA,EACvC;AACD;AAEO,IAAM,QAAe,IAAI,MAAM;;;ACvC/B,IAAM,mBAAN,MAAuB;AAAA,EAI7B,YAAY,OAAkD,SAAkB;AAC/E,SAAK,QAAQ;AACb,SAAK,UAAU;AAAA,EAChB;AACD;","names":["OpenAI"]}
package/dist/index.mjs CHANGED
@@ -227,113 +227,6 @@ var FunctionCallOutput = class _FunctionCallOutput extends ContextItem {
227
227
  }
228
228
  };
229
229
 
230
- // src/core/context-engine/condition/condition.ts
231
- var BaseCondition = class {
232
- and(other) {
233
- return new AndCondition(this, other);
234
- }
235
- or(other) {
236
- return new OrCondition(this, other);
237
- }
238
- not() {
239
- return new NotCondition(this);
240
- }
241
- };
242
- var AndCondition = class extends BaseCondition {
243
- constructor(left, right) {
244
- super();
245
- this.left = left;
246
- this.right = right;
247
- }
248
- isSatisfiedBy(candidate) {
249
- return this.left.isSatisfiedBy(candidate) && this.right.isSatisfiedBy(candidate);
250
- }
251
- };
252
- var NotCondition = class extends BaseCondition {
253
- constructor(condition) {
254
- super();
255
- this.condition = condition;
256
- }
257
- isSatisfiedBy(candidate) {
258
- return !this.condition.isSatisfiedBy(candidate);
259
- }
260
- };
261
- var OrCondition = class extends BaseCondition {
262
- constructor(left, right) {
263
- super();
264
- this.left = left;
265
- this.right = right;
266
- }
267
- isSatisfiedBy(candidate) {
268
- return this.left.isSatisfiedBy(candidate) || this.right.isSatisfiedBy(candidate);
269
- }
270
- };
271
-
272
- // src/core/context-engine/rule/rule.ts
273
- var Rule = class {
274
- constructor({ when, then }) {
275
- this.condition = when;
276
- this.action = then;
277
- }
278
- apply(candidate) {
279
- if (this.condition.isSatisfiedBy(candidate)) {
280
- return this.action.apply(candidate);
281
- }
282
- return candidate;
283
- }
284
- };
285
-
286
- // src/core/generative-model/capabilities/capability.ts
287
- var Capability = class {
288
- };
289
-
290
- // src/core/generative-model/capabilities/reasoning-effort.ts
291
- var ReasoningEffort = class extends Capability {
292
- constructor(supportedEfforts, defaultEffort) {
293
- super();
294
- this.capability = "reasoning-effort";
295
- this.supportedEfforts = supportedEfforts;
296
- this.reasoningEffort = defaultEffort;
297
- }
298
- setReasoningEffort(effort) {
299
- if (!this.supportedEfforts.includes(effort)) {
300
- throw new Error(`Invalid reasoning effort: ${effort}`);
301
- }
302
- this.reasoningEffort = effort;
303
- }
304
- getReasoningEffort() {
305
- return this.reasoningEffort;
306
- }
307
- };
308
-
309
- // src/providers/openai/rules/reasoning-effort.ts
310
- var ReasoningEffortSupported = class extends BaseCondition {
311
- isSatisfiedBy(candidate) {
312
- return candidate.model.capabilities.some((capability) => capability instanceof ReasoningEffort);
313
- }
314
- };
315
- var SetReasoningEffort = class {
316
- apply(candidate) {
317
- const reasoningCapability = candidate.model.capabilities.find(
318
- (capability) => capability instanceof ReasoningEffort
319
- );
320
- if (reasoningCapability) {
321
- const providerRequest = candidate.providerRequest;
322
- candidate.providerRequest = {
323
- ...providerRequest,
324
- reasoning: {
325
- effort: reasoningCapability.getReasoningEffort()
326
- }
327
- };
328
- }
329
- return candidate;
330
- }
331
- };
332
- var reasoningEffortRule = new Rule({
333
- when: new ReasoningEffortSupported(),
334
- then: new SetReasoningEffort()
335
- });
336
-
337
230
  // src/providers/openai/runtime/openai-responses.ts
338
231
  import OpenAI from "openai";
339
232
  var OpenAIResponses = class {
@@ -342,12 +235,17 @@ var OpenAIResponses = class {
342
235
  }
343
236
  async infer(inferenceRequest) {
344
237
  const input = this.mapContextToRequest(inferenceRequest.context);
345
- reasoningEffortRule.apply(inferenceRequest);
346
- const response = await this.client.responses.create({
347
- model: inferenceRequest.model.id,
348
- input,
349
- ...inferenceRequest.providerRequest
350
- });
238
+ const specification = inferenceRequest.model.specification;
239
+ let request = {
240
+ model: specification.name,
241
+ input
242
+ };
243
+ if (specification.supportReasoningEffort) {
244
+ request.reasoning = {
245
+ effort: inferenceRequest.model.getReasoningEffort()
246
+ };
247
+ }
248
+ const response = await this.client.responses.create(request);
351
249
  return this.extractContextItems(response);
352
250
  }
353
251
  mapContextToRequest(context) {
@@ -369,14 +267,37 @@ var OpenAIResponses = class {
369
267
  };
370
268
 
371
269
  // src/providers/openai/models/gpt-5-4.ts
372
- var openaiReasoningEffort = new ReasoningEffort(
373
- ["xhigh", "high", "medium", "low", "none"],
374
- "none"
375
- );
270
+ var OpenAIReasoningEffort = class {
271
+ constructor(reasoningEffort) {
272
+ this.reasoningEffort = reasoningEffort;
273
+ }
274
+ setReasoningEffort(effort) {
275
+ this.reasoningEffort = effort;
276
+ }
277
+ getReasoningEffort() {
278
+ if (!this.reasoningEffort) {
279
+ throw new Error("Reasoning effort not supported");
280
+ }
281
+ return this.reasoningEffort;
282
+ }
283
+ };
376
284
  var GPT54 = class {
377
285
  constructor() {
378
- this.id = "gpt-5.4";
379
- this.capabilities = [openaiReasoningEffort];
286
+ this.specification = {
287
+ name: "gpt-5.4",
288
+ supportReasoningEffort: true,
289
+ defaultReasoningEffort: "none",
290
+ supportStreaming: true
291
+ };
292
+ this.effort = new OpenAIReasoningEffort(
293
+ this.specification.defaultReasoningEffort
294
+ );
295
+ }
296
+ setReasoningEffort(effort) {
297
+ this.effort.setReasoningEffort(effort);
298
+ }
299
+ getReasoningEffort() {
300
+ return this.effort.getReasoningEffort();
380
301
  }
381
302
  };
382
303
  var gpt54 = new GPT54();
@@ -386,7 +307,6 @@ var InferenceRequest = class {
386
307
  constructor(model, context) {
387
308
  this.model = model;
388
309
  this.context = context;
389
- this.providerRequest = {};
390
310
  }
391
311
  };
392
312
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/context-runtime/context.ts","../src/core/context-runtime/context-item.ts","../src/core/context-runtime/content.ts","../src/core/context-runtime/content/input-text.ts","../src/core/context-runtime/input/user-message.ts","../src/core/context-runtime/input/developer-message.ts","../src/core/context-runtime/content/output-text.ts","../src/core/context-runtime/output/model-message.ts","../src/core/context-runtime/output/function-call.ts","../src/core/context-runtime/output/reasoning.ts","../src/core/context-runtime/input/function-call-output.ts","../src/core/context-engine/condition/condition.ts","../src/core/context-engine/rule/rule.ts","../src/core/generative-model/capabilities/capability.ts","../src/core/generative-model/capabilities/reasoning-effort.ts","../src/providers/openai/rules/reasoning-effort.ts","../src/providers/openai/runtime/openai-responses.ts","../src/providers/openai/models/gpt-5-4.ts","../src/core/generative-model/inference-request.ts"],"sourcesContent":["import { ContextItem } from \"@core/context-runtime/context-item\"\n\nexport class Context {\n\treadonly id: string\n\treadonly projectId: string\n\treadonly items: ContextItem[]\n\n\tconstructor(id: string, projectId: string, items: ContextItem[]) {\n\t\tthis.projectId = projectId\n\t\tthis.id = id\n\t\tthis.items = items\n\t}\n\n\taddItem(item: ContextItem): Context {\n\t\tthis.items.push(item)\n\t\treturn this\n\t}\n\n\tapplyModelOutput(items: ContextItem[]): Context {\n\t\tfor (const item of items) {\n\t\t\tconst itemType = item.getType()\n\t\t\tif (itemType !== \"function_call\" && itemType !== \"message\" && itemType !== \"reasoning\") {\n\t\t\t\tthrow new Error(`Invalid item type: ${itemType}`)\n\t\t\t}\n\t\t}\n\t\tthis.items.push(...items)\n\t\treturn this\n\t}\n\n\tgetItems(): ContextItem[] {\n\t\treturn this.items\n\t}\n\n\tstatic create(projectId: string): Context {\n\t\tconst id = crypto.randomUUID()\n\t\treturn new Context(id, projectId, [])\n\t}\n\n\tstatic rehydrate(data: { id: string; projectId: string; items: ContextItem[] }): Context {\n\t\treturn new Context(data.id, data.projectId, data.items)\n\t}\n\n\ttoJSON(): any {\n\t\treturn this.items.map((item) => item.toJSON())\n\t}\n}\n","export abstract class ContextItem {\n\tabstract readonly type: string\n\n\tgetType(): string {\n\t\treturn this.type\n\t}\n\n\tabstract toJSON(): any\n}\n","export abstract class Content {\n\tabstract readonly type: string\n}\n","import { Content } from \"@core/context-runtime/content\"\n\nexport class InputText extends Content {\n\treadonly type = \"input_text\"\n\n\tprivate constructor(public readonly text: string) {\n\t\tsuper()\n\t}\n\n\tstatic create(text: string): InputText {\n\t\treturn new InputText(text)\n\t}\n\n\tstatic rehydrate(data: { text: string }): InputText {\n\t\treturn new InputText(data.text)\n\t}\n\n\ttoJSON(): any[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\ttype: this.type,\n\t\t\t\ttext: this.text,\n\t\t\t},\n\t\t]\n\t}\n}\n","import { ContextItem } from \"@core/context-runtime/context-item\"\nimport { InputText } from \"@core/context-runtime/content/input-text\"\n\nexport class UserMessage extends ContextItem {\n\treadonly type = \"message\"\n\treadonly role = \"user\"\n\treadonly content: InputText\n\n\tprivate constructor(content: InputText) {\n\t\tsuper()\n\t\tthis.content = content\n\t}\n\n\tstatic create(text: string): UserMessage {\n\t\tconst content = InputText.create(text)\n\t\treturn new UserMessage(content)\n\t}\n\n\tstatic rehydrate(data: { text: string }): UserMessage {\n\t\tconst content = InputText.rehydrate(data)\n\t\treturn new UserMessage(content)\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\trole: this.role,\n\t\t\tcontent: this.content.toJSON(),\n\t\t}\n\t}\n}\n","import { InputText } from \"@core/context-runtime/content/input-text\"\nimport { ContextItem } from \"@core/context-runtime/context-item\"\n\nexport class DeveloperMessage extends ContextItem {\n\treadonly type = \"message\"\n\treadonly role = \"developer\"\n\treadonly content: InputText\n\n\tprivate constructor(content: InputText) {\n\t\tsuper()\n\t\tthis.content = content\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\trole: this.role,\n\t\t\tcontent: this.content.toJSON(),\n\t\t}\n\t}\n\n\tstatic create(text: string): DeveloperMessage {\n\t\tconst content = InputText.create(text)\n\t\treturn new DeveloperMessage(content)\n\t}\n\n\tstatic rehydrate(data: { text: string }): DeveloperMessage {\n\t\tconst content = InputText.rehydrate(data)\n\t\treturn new DeveloperMessage(content)\n\t}\n}\n","import { Content } from \"@core/context-runtime/content\"\n\nexport class OutputText extends Content {\n\treadonly type = \"output_text\"\n\n\tprivate constructor(public readonly text: string) {\n\t\tsuper()\n\t}\n\n\tstatic rehydrate(data: { text: string }): OutputText {\n\t\treturn new OutputText(data.text)\n\t}\n\n\ttoJSON(): any[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\ttype: this.type,\n\t\t\t\ttext: this.text,\n\t\t\t},\n\t\t]\n\t}\n}\n","import { ContextItem } from \"@core/context-runtime/context-item\"\nimport { OutputText } from \"@core/context-runtime/content/output-text\"\n\nexport class ModelMessage extends ContextItem {\n\treadonly type = \"message\"\n\treadonly role = \"assistant\"\n\treadonly content: OutputText\n\n\tprivate constructor(content: OutputText) {\n\t\tsuper()\n\t\tthis.content = content\n\t}\n\n\tstatic rehydrate(data: { text: string }): ModelMessage {\n\t\tconst content = OutputText.rehydrate(data)\n\t\treturn new ModelMessage(content)\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\trole: this.role,\n\t\t\tcontent: this.content.toJSON(),\n\t\t}\n\t}\n}\n","import { ContextItem } from \"@core/context-runtime/context-item\"\n\nexport class FunctionCall extends ContextItem {\n\treadonly type = \"function_call\"\n\treadonly callId: string\n\treadonly name: string\n\treadonly args: string\n\n\tprivate constructor(callId: string, name: string, args: string) {\n\t\tsuper()\n\t\tthis.callId = callId\n\t\tthis.name = name\n\t\tthis.args = args\n\t}\n\n\tstatic rehydrate(data: { callId: string; name: string; args: string }): FunctionCall {\n\t\treturn new FunctionCall(data.callId, data.name, data.args)\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\tcallId: this.callId,\n\t\t\tname: this.name,\n\t\t\targuments: this.args,\n\t\t}\n\t}\n}\n","import { InputText } from \"@core/context-runtime/content/input-text\"\nimport { SummaryText } from \"@core/context-runtime/content/summary-text\"\nimport { ContextItem } from \"@core/context-runtime/context-item\"\n\nexport class Reasoning extends ContextItem {\n\treadonly type = \"reasoning\"\n\treadonly content: InputText | undefined\n\treadonly encryptedContent: string | undefined\n\treadonly summary: SummaryText[]\n\n\tprivate constructor(\n\t\tcontent: InputText | undefined,\n\t\tencryptedContent?: string | undefined,\n\t\tsummary: SummaryText[] = [],\n\t) {\n\t\tsuper()\n\t\tthis.content = content\n\t\tthis.encryptedContent = encryptedContent\n\t\tthis.summary = summary\n\t}\n\n\tstatic rehydrate(data: {\n\t\tcontent: InputText | undefined\n\t\tencryptedContent: string | undefined\n\t\tsummary: SummaryText[]\n\t}): Reasoning {\n\t\treturn new Reasoning(data.content, data.encryptedContent, data.summary)\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\tcontent: this.content?.toJSON(),\n\t\t\tencryptedContent: this.encryptedContent,\n\t\t\tsummary: this.summary.map((s) => s.toJSON()),\n\t\t}\n\t}\n}\n","import { ContextItem } from \"@core/context-runtime/context-item\"\nimport { InputText } from \"@core/context-runtime/content/input-text\"\n\nexport class FunctionCallOutput extends ContextItem {\n\treadonly type = \"function_call_output\"\n\treadonly callId: string\n\treadonly output: InputText[]\n\n\tprivate constructor(callId: string, output: InputText[]) {\n\t\tsuper()\n\t\tthis.callId = callId\n\t\tthis.output = output\n\t}\n\n\tstatic create(callId: string, output: InputText[]): FunctionCallOutput {\n\t\treturn new FunctionCallOutput(callId, output)\n\t}\n\n\tstatic rehydrate(data: { callId: string; output: InputText[] }): FunctionCallOutput {\n\t\treturn new FunctionCallOutput(data.callId, data.output)\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\tcallId: this.callId,\n\t\t\toutput: this.output.map((o) => o.toJSON()),\n\t\t}\n\t}\n}\n","export interface Condition<T> {\n\tisSatisfiedBy(candidate: T): boolean\n\tand(other: Condition<T>): Condition<T>\n\tor(other: Condition<T>): Condition<T>\n\tnot(): Condition<T>\n}\n\nexport abstract class BaseCondition<T> implements Condition<T> {\n\tabstract isSatisfiedBy(candidate: T): boolean\n\n\tand(other: Condition<T>): Condition<T> {\n\t\treturn new AndCondition(this, other)\n\t}\n\n\tor(other: Condition<T>): Condition<T> {\n\t\treturn new OrCondition(this, other)\n\t}\n\n\tnot(): Condition<T> {\n\t\treturn new NotCondition(this)\n\t}\n}\n\nexport class AndCondition<T> extends BaseCondition<T> {\n\tconstructor(\n\t\tprivate readonly left: Condition<T>,\n\t\tprivate readonly right: Condition<T>,\n\t) {\n\t\tsuper()\n\t}\n\n\tisSatisfiedBy(candidate: T): boolean {\n\t\treturn this.left.isSatisfiedBy(candidate) && this.right.isSatisfiedBy(candidate)\n\t}\n}\n\nexport class NotCondition<T> extends BaseCondition<T> {\n\tconstructor(private readonly condition: Condition<T>) {\n\t\tsuper()\n\t}\n\n\tisSatisfiedBy(candidate: T): boolean {\n\t\treturn !this.condition.isSatisfiedBy(candidate)\n\t}\n}\n\nexport class OrCondition<T> extends BaseCondition<T> {\n\tconstructor(\n\t\tprivate readonly left: Condition<T>,\n\t\tprivate readonly right: Condition<T>,\n\t) {\n\t\tsuper()\n\t}\n\n\tisSatisfiedBy(candidate: T): boolean {\n\t\treturn this.left.isSatisfiedBy(candidate) || this.right.isSatisfiedBy(candidate)\n\t}\n}\n","import { Condition } from \"@core/context-engine/condition/condition\"\n\nexport interface Action<T> {\n\tapply(candidate: T): T\n}\n\nexport class Rule<T> {\n\tprivate condition: Condition<T>\n\tprivate action: Action<T>\n\n\tconstructor({ when, then }: { when: Condition<T>; then: Action<T> }) {\n\t\tthis.condition = when\t\n\t\tthis.action = then\n\t}\n\n\tapply(candidate: T): T {\n\t\tif (this.condition.isSatisfiedBy(candidate)) {\n\t\t\treturn this.action.apply(candidate)\n\t\t}\n\t\treturn candidate\n\t}\n}\n","export abstract class Capability {\n abstract readonly capability: string\n}","import { Capability } from \"./capability\"\n\nexport class ReasoningEffort<Effort extends string> extends Capability {\n\treadonly capability = \"reasoning-effort\"\n\treadonly supportedEfforts: readonly Effort[]\n\treasoningEffort: Effort\n\n\tconstructor(supportedEfforts: readonly Effort[], defaultEffort: Effort) {\n\t\tsuper()\n\t\tthis.supportedEfforts = supportedEfforts\n\t\tthis.reasoningEffort = defaultEffort\n\t}\n\n\tsetReasoningEffort(effort: Effort): void {\n\t\tif (!this.supportedEfforts.includes(effort)) {\n\t\t\tthrow new Error(`Invalid reasoning effort: ${effort}`)\n\t\t}\n\t\tthis.reasoningEffort = effort;\n\t}\n\n\tgetReasoningEffort(): Effort {\n\t\treturn this.reasoningEffort\n\t}\n}\n","import { BaseCondition } from \"@core/context-engine/condition/condition\"\nimport { Action, Rule } from \"@core/context-engine/rule/rule\"\nimport { ReasoningEffort } from \"@core/generative-model/capabilities/reasoning-effort\"\nimport { InferenceRequest } from \"@core/generative-model/inference-request\"\n\nexport class ReasoningEffortSupported extends BaseCondition<InferenceRequest> {\n\tisSatisfiedBy(candidate: InferenceRequest): boolean {\n\t\treturn candidate.model.capabilities.some((capability) => capability instanceof ReasoningEffort)\n\t}\n}\n\nexport class SetReasoningEffort implements Action<InferenceRequest> {\n\tapply(candidate: InferenceRequest): InferenceRequest {\n\t\tconst reasoningCapability = candidate.model.capabilities.find(\n\t\t\t(capability) => capability instanceof ReasoningEffort,\n\t\t)\n\t\tif (reasoningCapability) {\n\t\t\tconst providerRequest = candidate.providerRequest\n\t\t\tcandidate.providerRequest = {\n\t\t\t\t...providerRequest,\n\t\t\t\treasoning: {\n\t\t\t\t\teffort: reasoningCapability.getReasoningEffort(),\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\t\treturn candidate\n\t}\n}\nexport const reasoningEffortRule = new Rule({\n\twhen: new ReasoningEffortSupported(),\n\tthen: new SetReasoningEffort(),\n})\n","import { Context } from \"@core/context-runtime/context\"\nimport { ContextItem } from \"@core/context-runtime/context-item\"\nimport { FunctionCall } from \"@core/context-runtime/output/function-call\"\nimport { ModelMessage } from \"@core/context-runtime/output/model-message\"\nimport { Reasoning } from \"@core/context-runtime/output/reasoning\"\nimport { InferenceRequest } from \"@core/generative-model/inference-request\"\nimport { ModelRuntime } from \"@core/generative-model/runtime/model-runtime\"\nimport { reasoningEffortRule } from \"@openai/rules/reasoning-effort\"\nimport OpenAI from \"openai\"\n\nexport class OpenAIResponses implements ModelRuntime {\n\tprivate readonly client: OpenAI\n\n\tconstructor() {\n\t\tthis.client = new OpenAI()\n\t}\n\n\tasync infer(inferenceRequest: InferenceRequest): Promise<ContextItem[]> {\n\t\tconst input = this.mapContextToRequest(inferenceRequest.context)\n\n\t\treasoningEffortRule.apply(inferenceRequest)\n\n\t\tconst response = await this.client.responses.create({\n\t\t\tmodel: inferenceRequest.model.id,\n\t\t\tinput: input,\n\t\t\t...inferenceRequest.providerRequest,\n\t\t})\n\n\t\treturn this.extractContextItems(response)\n\t}\n\n\tmapContextToRequest(context: Context): any[] {\n\t\treturn context.getItems().map((item) => item.toJSON())\n\t}\n\n\textractContextItems(response: any): ContextItem[] {\n\t\treturn response.output.map((item: any) => {\n\t\t\tif (item.type === \"message\" && item.status === \"completed\") {\n\t\t\t\treturn ModelMessage.rehydrate(item.content[0] as { text: string })\n\t\t\t}\n\t\t\tif (item.type === \"function_call\" && item.status === \"completed\") {\n\t\t\t\treturn FunctionCall.rehydrate(item)\n\t\t\t}\n\t\t\tif (item.type === \"reasoning\") {\n\t\t\t\treturn Reasoning.rehydrate(item)\n\t\t\t}\n\t\t})\n\t}\n}\n","import { Capability } from \"@core/generative-model/capabilities/capability\"\nimport { ReasoningEffort } from \"@core/generative-model/capabilities/reasoning-effort\"\nimport { GenerativeModel } from \"@core/generative-model/generative-model\"\n\nexport const openaiReasoningEffort = new ReasoningEffort<\"xhigh\" | \"high\" | \"medium\" | \"low\" | \"none\">(\n\t[\"xhigh\", \"high\", \"medium\", \"low\", \"none\"],\n\t\"none\",\n)\n\nexport class GPT54 implements GenerativeModel<\"gpt-5.4\"> {\n\treadonly id = \"gpt-5.4\"\n\treadonly capabilities: Capability[] = [openaiReasoningEffort]\n}\n\nexport const gpt54 = new GPT54()\n","import { Context } from \"@core/context-runtime/context\"\nimport { GenerativeModel } from \"./generative-model\"\n\nexport class InferenceRequest {\n\treadonly model: GenerativeModel<string>\n\treadonly context: Context\n providerRequest: Record<string, unknown>\n\n\tconstructor(model: GenerativeModel<string>, context: Context) {\n\t\tthis.model = model\n\t\tthis.context = context\n\t\tthis.providerRequest = {}\n\t}\n}"],"mappings":";AAEO,IAAM,UAAN,MAAM,SAAQ;AAAA,EAKpB,YAAY,IAAY,WAAmB,OAAsB;AAChE,SAAK,YAAY;AACjB,SAAK,KAAK;AACV,SAAK,QAAQ;AAAA,EACd;AAAA,EAEA,QAAQ,MAA4B;AACnC,SAAK,MAAM,KAAK,IAAI;AACpB,WAAO;AAAA,EACR;AAAA,EAEA,iBAAiB,OAA+B;AAC/C,eAAW,Q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AN,MAAkD;AAAA,EAAlD;AACN,SAAS,KAAK;AACd,SAAS,eAA6B,CAAC,qBAAqB;AAAA;AAC7D;AAEO,IAAM,QAAQ,IAAI,MAAM;;;ACXxB,IAAM,mBAAN,MAAuB;AAAA,EAK7B,YAAY,OAAgC,SAAkB;AAC7D,SAAK,QAAQ;AACb,SAAK,UAAU;AACf,SAAK,kBAAkB,CAAC;AAAA,EACzB;AACD;","names":[]}
1
+ {"version":3,"sources":["../src/core/context-runtime/context.ts","../src/core/context-runtime/context-item.ts","../src/core/context-runtime/content.ts","../src/core/context-runtime/content/input-text.ts","../src/core/context-runtime/input/user-message.ts","../src/core/context-runtime/input/developer-message.ts","../src/core/context-runtime/content/output-text.ts","../src/core/context-runtime/output/model-message.ts","../src/core/context-runtime/output/function-call.ts","../src/core/context-runtime/output/reasoning.ts","../src/core/context-runtime/input/function-call-output.ts","../src/providers/openai/runtime/openai-responses.ts","../src/providers/openai/models/gpt-5-4.ts","../src/core/generative-model/inference-request.ts"],"sourcesContent":["import { ContextItem } from \"@core/context-runtime/context-item\"\n\nexport class Context {\n\treadonly id: string\n\treadonly projectId: string\n\treadonly items: ContextItem[]\n\n\tconstructor(id: string, projectId: string, items: ContextItem[]) {\n\t\tthis.projectId = projectId\n\t\tthis.id = id\n\t\tthis.items = items\n\t}\n\n\taddItem(item: ContextItem): Context {\n\t\tthis.items.push(item)\n\t\treturn this\n\t}\n\n\tapplyModelOutput(items: ContextItem[]): Context {\n\t\tfor (const item of items) {\n\t\t\tconst itemType = item.getType()\n\t\t\tif (itemType !== \"function_call\" && itemType !== \"message\" && itemType !== \"reasoning\") {\n\t\t\t\tthrow new Error(`Invalid item type: ${itemType}`)\n\t\t\t}\n\t\t}\n\t\tthis.items.push(...items)\n\t\treturn this\n\t}\n\n\tgetItems(): ContextItem[] {\n\t\treturn this.items\n\t}\n\n\tstatic create(projectId: string): Context {\n\t\tconst id = crypto.randomUUID()\n\t\treturn new Context(id, projectId, [])\n\t}\n\n\tstatic rehydrate(data: { id: string; projectId: string; items: ContextItem[] }): Context {\n\t\treturn new Context(data.id, data.projectId, data.items)\n\t}\n\n\ttoJSON(): any {\n\t\treturn this.items.map((item) => item.toJSON())\n\t}\n}\n","export abstract class ContextItem {\n\tabstract readonly type: string\n\n\tgetType(): string {\n\t\treturn this.type\n\t}\n\n\tabstract toJSON(): any\n}\n","export abstract class Content {\n\tabstract readonly type: string\n}\n","import { Content } from \"@core/context-runtime/content\"\n\nexport class InputText extends Content {\n\treadonly type = \"input_text\"\n\n\tprivate constructor(public readonly text: string) {\n\t\tsuper()\n\t}\n\n\tstatic create(text: string): InputText {\n\t\treturn new InputText(text)\n\t}\n\n\tstatic rehydrate(data: { text: string }): InputText {\n\t\treturn new InputText(data.text)\n\t}\n\n\ttoJSON(): any[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\ttype: this.type,\n\t\t\t\ttext: this.text,\n\t\t\t},\n\t\t]\n\t}\n}\n","import { ContextItem } from \"@core/context-runtime/context-item\"\nimport { InputText } from \"@core/context-runtime/content/input-text\"\n\nexport class UserMessage extends ContextItem {\n\treadonly type = \"message\"\n\treadonly role = \"user\"\n\treadonly content: InputText\n\n\tprivate constructor(content: InputText) {\n\t\tsuper()\n\t\tthis.content = content\n\t}\n\n\tstatic create(text: string): UserMessage {\n\t\tconst content = InputText.create(text)\n\t\treturn new UserMessage(content)\n\t}\n\n\tstatic rehydrate(data: { text: string }): UserMessage {\n\t\tconst content = InputText.rehydrate(data)\n\t\treturn new UserMessage(content)\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\trole: this.role,\n\t\t\tcontent: this.content.toJSON(),\n\t\t}\n\t}\n}\n","import { InputText } from \"@core/context-runtime/content/input-text\"\nimport { ContextItem } from \"@core/context-runtime/context-item\"\n\nexport class DeveloperMessage extends ContextItem {\n\treadonly type = \"message\"\n\treadonly role = \"developer\"\n\treadonly content: InputText\n\n\tprivate constructor(content: InputText) {\n\t\tsuper()\n\t\tthis.content = content\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\trole: this.role,\n\t\t\tcontent: this.content.toJSON(),\n\t\t}\n\t}\n\n\tstatic create(text: string): DeveloperMessage {\n\t\tconst content = InputText.create(text)\n\t\treturn new DeveloperMessage(content)\n\t}\n\n\tstatic rehydrate(data: { text: string }): DeveloperMessage {\n\t\tconst content = InputText.rehydrate(data)\n\t\treturn new DeveloperMessage(content)\n\t}\n}\n","import { Content } from \"@core/context-runtime/content\"\n\nexport class OutputText extends Content {\n\treadonly type = \"output_text\"\n\n\tprivate constructor(public readonly text: string) {\n\t\tsuper()\n\t}\n\n\tstatic rehydrate(data: { text: string }): OutputText {\n\t\treturn new OutputText(data.text)\n\t}\n\n\ttoJSON(): any[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\ttype: this.type,\n\t\t\t\ttext: this.text,\n\t\t\t},\n\t\t]\n\t}\n}\n","import { ContextItem } from \"@core/context-runtime/context-item\"\nimport { OutputText } from \"@core/context-runtime/content/output-text\"\n\nexport class ModelMessage extends ContextItem {\n\treadonly type = \"message\"\n\treadonly role = \"assistant\"\n\treadonly content: OutputText\n\n\tprivate constructor(content: OutputText) {\n\t\tsuper()\n\t\tthis.content = content\n\t}\n\n\tstatic rehydrate(data: { text: string }): ModelMessage {\n\t\tconst content = OutputText.rehydrate(data)\n\t\treturn new ModelMessage(content)\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\trole: this.role,\n\t\t\tcontent: this.content.toJSON(),\n\t\t}\n\t}\n}\n","import { ContextItem } from \"@core/context-runtime/context-item\"\n\nexport class FunctionCall extends ContextItem {\n\treadonly type = \"function_call\"\n\treadonly callId: string\n\treadonly name: string\n\treadonly args: string\n\n\tprivate constructor(callId: string, name: string, args: string) {\n\t\tsuper()\n\t\tthis.callId = callId\n\t\tthis.name = name\n\t\tthis.args = args\n\t}\n\n\tstatic rehydrate(data: { callId: string; name: string; args: string }): FunctionCall {\n\t\treturn new FunctionCall(data.callId, data.name, data.args)\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\tcallId: this.callId,\n\t\t\tname: this.name,\n\t\t\targuments: this.args,\n\t\t}\n\t}\n}\n","import { InputText } from \"@core/context-runtime/content/input-text\"\nimport { SummaryText } from \"@core/context-runtime/content/summary-text\"\nimport { ContextItem } from \"@core/context-runtime/context-item\"\n\nexport class Reasoning extends ContextItem {\n\treadonly type = \"reasoning\"\n\treadonly content: InputText | undefined\n\treadonly encryptedContent: string | undefined\n\treadonly summary: SummaryText[]\n\n\tprivate constructor(\n\t\tcontent: InputText | undefined,\n\t\tencryptedContent?: string | undefined,\n\t\tsummary: SummaryText[] = [],\n\t) {\n\t\tsuper()\n\t\tthis.content = content\n\t\tthis.encryptedContent = encryptedContent\n\t\tthis.summary = summary\n\t}\n\n\tstatic rehydrate(data: {\n\t\tcontent: InputText | undefined\n\t\tencryptedContent: string | undefined\n\t\tsummary: SummaryText[]\n\t}): Reasoning {\n\t\treturn new Reasoning(data.content, data.encryptedContent, data.summary)\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\tcontent: this.content?.toJSON(),\n\t\t\tencryptedContent: this.encryptedContent,\n\t\t\tsummary: this.summary.map((s) => s.toJSON()),\n\t\t}\n\t}\n}\n","import { ContextItem } from \"@core/context-runtime/context-item\"\nimport { InputText } from \"@core/context-runtime/content/input-text\"\n\nexport class FunctionCallOutput extends ContextItem {\n\treadonly type = \"function_call_output\"\n\treadonly callId: string\n\treadonly output: InputText[]\n\n\tprivate constructor(callId: string, output: InputText[]) {\n\t\tsuper()\n\t\tthis.callId = callId\n\t\tthis.output = output\n\t}\n\n\tstatic create(callId: string, output: InputText[]): FunctionCallOutput {\n\t\treturn new FunctionCallOutput(callId, output)\n\t}\n\n\tstatic rehydrate(data: { callId: string; output: InputText[] }): FunctionCallOutput {\n\t\treturn new FunctionCallOutput(data.callId, data.output)\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\tcallId: this.callId,\n\t\t\toutput: this.output.map((o) => o.toJSON()),\n\t\t}\n\t}\n}\n","import { Context } from \"@core/context-runtime/context\"\nimport { ContextItem } from \"@core/context-runtime/context-item\"\nimport { FunctionCall } from \"@core/context-runtime/output/function-call\"\nimport { ModelMessage } from \"@core/context-runtime/output/model-message\"\nimport { Reasoning } from \"@core/context-runtime/output/reasoning\"\nimport { InferenceRequest } from \"@core/generative-model/inference-request\"\nimport { ModelRuntime } from \"@core/generative-model/runtime/model-runtime\"\nimport OpenAI from \"openai\"\n\nexport class OpenAIResponses implements ModelRuntime {\n\tprivate readonly client: OpenAI\n\tconstructor() {\n\t\tthis.client = new OpenAI()\n\t}\n\n\tasync infer(inferenceRequest: InferenceRequest): Promise<ContextItem[]> {\n\t\tconst input = this.mapContextToRequest(inferenceRequest.context)\n\n\t\tconst specification = inferenceRequest.model.specification\n\t\tlet request: any = {\n\t\t\tmodel: specification.name,\n\t\t\tinput: input,\n\t\t}\n\n\t\tif (specification.supportReasoningEffort) {\n\t\t\trequest.reasoning = {\n\t\t\t\teffort: inferenceRequest.model.getReasoningEffort(),\n\t\t\t}\n\t\t}\n\n\t\tconst response = await this.client.responses.create(request)\n\n\t\treturn this.extractContextItems(response)\n\t}\n\n\tmapContextToRequest(context: Context): any[] {\n\t\treturn context.getItems().map((item) => item.toJSON())\n\t}\n\n\textractContextItems(response: any): ContextItem[] {\n\t\treturn response.output.map((item: any) => {\n\t\t\tif (item.type === \"message\" && item.status === \"completed\") {\n\t\t\t\treturn ModelMessage.rehydrate(item.content[0] as { text: string })\n\t\t\t}\n\t\t\tif (item.type === \"function_call\" && item.status === \"completed\") {\n\t\t\t\treturn FunctionCall.rehydrate(item)\n\t\t\t}\n\t\t\tif (item.type === \"reasoning\") {\n\t\t\t\treturn Reasoning.rehydrate(item)\n\t\t\t}\n\t\t})\n\t}\n}\n","import { ReasoningEffort } from \"@core/generative-model/capabilities/reasoning-effort\"\nimport { GenerativeModel } from \"@core/generative-model/generative-model\"\n\nexport type OpenAIReasoningEffortType = \"xhigh\" | \"high\" | \"medium\" | \"low\" | \"none\"\n\nexport class OpenAIReasoningEffort implements ReasoningEffort<OpenAIReasoningEffortType> {\n\treasoningEffort: OpenAIReasoningEffortType\n\n\tconstructor(reasoningEffort: OpenAIReasoningEffortType) {\n\t\tthis.reasoningEffort = reasoningEffort\n\t}\n\n\tsetReasoningEffort(effort: OpenAIReasoningEffortType): void {\n\t\tthis.reasoningEffort = effort\n\t}\n\tgetReasoningEffort(): OpenAIReasoningEffortType {\n\t\tif (!this.reasoningEffort) {\n\t\t\tthrow new Error(\"Reasoning effort not supported\")\n\t\t}\n\t\treturn this.reasoningEffort\n\t}\n}\n\nexport class GPT54 implements GenerativeModel, ReasoningEffort<OpenAIReasoningEffortType> {\n\treadonly specification = {\n\t\tname: \"gpt-5.4\",\n\t\tsupportReasoningEffort: true,\n\t\tdefaultReasoningEffort: \"none\" as OpenAIReasoningEffortType,\n\t\tsupportStreaming: true,\n\t}\n\n\tprivate readonly effort: OpenAIReasoningEffort = new OpenAIReasoningEffort(\n\t\tthis.specification.defaultReasoningEffort,\n\t)\n\n\tsetReasoningEffort(effort: OpenAIReasoningEffortType): void {\n\t\tthis.effort.setReasoningEffort(effort)\n\t}\n\tgetReasoningEffort(): OpenAIReasoningEffortType {\n\t\treturn this.effort.getReasoningEffort()\n\t}\n}\n\nexport const gpt54: GPT54 = new GPT54()\n","import { Context } from \"@core/context-runtime/context\"\nimport { GenerativeModel } from \"./generative-model\"\nimport { ReasoningEffort } from \"./capabilities/reasoning-effort\"\n\nexport class InferenceRequest {\n\treadonly model: GenerativeModel & ReasoningEffort<string>\n\treadonly context: Context\n\n\tconstructor(model: GenerativeModel & ReasoningEffort<string>, context: Context) {\n\t\tthis.model = model\n\t\tthis.context = context\n\t}\n}\n"],"mappings":";AAEO,IAAM,UAAN,MAA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ACvC;AACD;AAEO,IAAM,QAAe,IAAI,MAAM;;;ACvC/B,IAAM,mBAAN,MAAuB;AAAA,EAI7B,YAAY,OAAkD,SAAkB;AAC/E,SAAK,QAAQ;AACb,SAAK,UAAU;AAAA,EAChB;AACD;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mozaik-ai/core",
3
- "version": "2.4.4",
3
+ "version": "2.5.0",
4
4
  "description": "A TypeScript library for building AI agents",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",