@theokit/agents 2.0.0 → 4.0.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/{bridge-entry-F9kHGaIn.d.ts → bridge-entry-Ddu3Ug_3.d.ts} +44 -22
- package/dist/bridge.d.ts +1 -1
- package/dist/bridge.js +5 -5
- package/dist/{chunk-K3VX4S65.js → chunk-OKG5LRGV.js} +87 -22
- package/dist/chunk-OKG5LRGV.js.map +1 -0
- package/dist/index.d.ts +133 -20
- package/dist/index.js +210 -119
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-K3VX4S65.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AGENT_BRAND,
|
|
3
|
+
AgentBuilder,
|
|
3
4
|
AgentDefinitionError,
|
|
4
5
|
AgentRunner,
|
|
5
6
|
AgentRunnerBuilder,
|
|
6
7
|
BudgetExceededError,
|
|
7
8
|
ConfigurationError,
|
|
9
|
+
ContextualTool,
|
|
8
10
|
CostBudgetExceededError,
|
|
9
11
|
DEFAULT_KEEP_TOKENS,
|
|
10
12
|
DEFAULT_MAX_ITERATIONS,
|
|
11
13
|
DelegationError,
|
|
12
14
|
GuardrailViolationError,
|
|
13
|
-
agent,
|
|
14
15
|
agentsPlugin,
|
|
15
16
|
buildModelSelection,
|
|
16
17
|
compactionStrategyConfigSchema,
|
|
@@ -22,7 +23,6 @@ import {
|
|
|
22
23
|
compileSkills,
|
|
23
24
|
compileSkillsSelection,
|
|
24
25
|
compileTools,
|
|
25
|
-
contextualTool,
|
|
26
26
|
costGuard,
|
|
27
27
|
createAgentExecutionContext,
|
|
28
28
|
createApiErrorHandler,
|
|
@@ -70,7 +70,7 @@ import {
|
|
|
70
70
|
toolRuntimeName,
|
|
71
71
|
translateSdkEvent,
|
|
72
72
|
unicodeNormalizer
|
|
73
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-OKG5LRGV.js";
|
|
74
74
|
import {
|
|
75
75
|
__name
|
|
76
76
|
} from "./chunk-7QVYU63E.js";
|
|
@@ -177,66 +177,71 @@ var ToolsCapability = class {
|
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
179
|
};
|
|
180
|
-
var
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
continue;
|
|
190
|
-
}
|
|
191
|
-
if (typeof e !== "object" || e === null || Array.isArray(e)) {
|
|
192
|
-
throw new ConfigurationError(`skills: entrada inv\xE1lida (${describe(e)}) \u2014 use um nome ou um skill inline`);
|
|
180
|
+
var SkillsCapability = class {
|
|
181
|
+
static {
|
|
182
|
+
__name(this, "SkillsCapability");
|
|
183
|
+
}
|
|
184
|
+
name = "skills";
|
|
185
|
+
#entries;
|
|
186
|
+
constructor(entries) {
|
|
187
|
+
if (!Array.isArray(entries)) {
|
|
188
|
+
throw new ConfigurationError(`skills: esperava array de nomes, recebi ${describe(entries)}`);
|
|
193
189
|
}
|
|
194
|
-
for (const
|
|
195
|
-
"
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
190
|
+
for (const e of entries) {
|
|
191
|
+
if (typeof e === "string") {
|
|
192
|
+
if (e.trim().length === 0) {
|
|
193
|
+
throw new ConfigurationError("skills: nome vazio \u2014 use um nome de skill n\xE3o vazio");
|
|
194
|
+
}
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if (typeof e !== "object" || e === null || Array.isArray(e)) {
|
|
198
|
+
throw new ConfigurationError(`skills: entrada inv\xE1lida (${describe(e)}) \u2014 use um nome ou um skill inline`);
|
|
199
|
+
}
|
|
200
|
+
for (const field of [
|
|
201
|
+
"name",
|
|
202
|
+
"description",
|
|
203
|
+
"instructions"
|
|
204
|
+
]) {
|
|
205
|
+
const value = e[field];
|
|
206
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
207
|
+
throw new ConfigurationError(`skills: skill inline sem \`${field}\` v\xE1lido (${describe(value)}) \u2014 name, description e instructions s\xE3o obrigat\xF3rios`);
|
|
208
|
+
}
|
|
202
209
|
}
|
|
203
210
|
}
|
|
211
|
+
this.#entries = entries;
|
|
204
212
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
...
|
|
220
|
-
enabled
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
inline
|
|
226
|
-
...previous.inline ?? [],
|
|
227
|
-
...compiled.skills.inline ?? []
|
|
228
|
-
]
|
|
229
|
-
} : {}
|
|
230
|
-
};
|
|
231
|
-
draft.provenance.push({
|
|
232
|
-
capability: "skills",
|
|
233
|
-
contributed: [
|
|
234
|
-
"skills"
|
|
213
|
+
apply(draft) {
|
|
214
|
+
const compiled = compileSkillsSelection(this.#entries.slice());
|
|
215
|
+
if (compiled.skills === void 0) return;
|
|
216
|
+
const previous = draft.skills;
|
|
217
|
+
draft.skills = previous === void 0 ? compiled.skills : {
|
|
218
|
+
// The spread is exhaustive only because `compileSkillsSelection` emits a FIXED 3-key
|
|
219
|
+
// shape (`enabled`, `autoInject: true`, and `inline` iff non-empty) — `enabled` and
|
|
220
|
+
// `inline` are both re-derived below, and `autoInject` is the same literal on both
|
|
221
|
+
// sides. TRAP for the future: if a capability ever authors `autoInject: false`, this
|
|
222
|
+
// spread would silently normalize it back to `true`. Unreachable today (no capability
|
|
223
|
+
// and no reference array form can express it) — revisit when one can.
|
|
224
|
+
...previous,
|
|
225
|
+
...compiled.skills,
|
|
226
|
+
enabled: [
|
|
227
|
+
...previous.enabled ?? [],
|
|
228
|
+
...compiled.skills.enabled ?? []
|
|
229
|
+
],
|
|
230
|
+
...previous.inline !== void 0 || compiled.skills.inline !== void 0 ? {
|
|
231
|
+
inline: [
|
|
232
|
+
...previous.inline ?? [],
|
|
233
|
+
...compiled.skills.inline ?? []
|
|
235
234
|
]
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
|
|
235
|
+
} : {}
|
|
236
|
+
};
|
|
237
|
+
draft.provenance.push({
|
|
238
|
+
capability: this.name,
|
|
239
|
+
contributed: [
|
|
240
|
+
"skills"
|
|
241
|
+
]
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
};
|
|
240
245
|
|
|
241
246
|
// src/capability/registry.ts
|
|
242
247
|
var UnknownCapabilityError = class extends Error {
|
|
@@ -287,62 +292,147 @@ var CapabilityPreset = class {
|
|
|
287
292
|
};
|
|
288
293
|
|
|
289
294
|
// src/capability/agent-capabilities.ts
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
var
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
295
|
+
var FieldCapability = class {
|
|
296
|
+
static {
|
|
297
|
+
__name(this, "FieldCapability");
|
|
298
|
+
}
|
|
299
|
+
value;
|
|
300
|
+
constructor(value) {
|
|
301
|
+
this.value = value;
|
|
302
|
+
}
|
|
303
|
+
apply(draft) {
|
|
304
|
+
setOnce(draft, this.field, this.value, this.name);
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
var MemoryCapability = class extends FieldCapability {
|
|
308
|
+
static {
|
|
309
|
+
__name(this, "MemoryCapability");
|
|
310
|
+
}
|
|
311
|
+
name = "memory";
|
|
312
|
+
field = "memory";
|
|
313
|
+
};
|
|
314
|
+
var ContextWindowCapability = class {
|
|
315
|
+
static {
|
|
316
|
+
__name(this, "ContextWindowCapability");
|
|
317
|
+
}
|
|
318
|
+
options;
|
|
319
|
+
name = "context-window";
|
|
320
|
+
constructor(options) {
|
|
321
|
+
this.options = options;
|
|
322
|
+
}
|
|
323
|
+
apply(draft) {
|
|
324
|
+
setOnce(draft, "context", compileContextWindow(this.options).context, this.name);
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
var ProjectContextCapability = class extends FieldCapability {
|
|
328
|
+
static {
|
|
329
|
+
__name(this, "ProjectContextCapability");
|
|
330
|
+
}
|
|
331
|
+
name = "project-context";
|
|
332
|
+
field = "projectContext";
|
|
333
|
+
};
|
|
334
|
+
var McpServersCapability = class extends FieldCapability {
|
|
335
|
+
static {
|
|
336
|
+
__name(this, "McpServersCapability");
|
|
337
|
+
}
|
|
338
|
+
name = "mcp";
|
|
339
|
+
field = "mcpServers";
|
|
340
|
+
};
|
|
341
|
+
var GuardrailsCapability = class extends FieldCapability {
|
|
342
|
+
static {
|
|
343
|
+
__name(this, "GuardrailsCapability");
|
|
344
|
+
}
|
|
345
|
+
name = "guardrails";
|
|
346
|
+
field = "guardrails";
|
|
347
|
+
};
|
|
348
|
+
var CheckpointCapability = class {
|
|
349
|
+
static {
|
|
350
|
+
__name(this, "CheckpointCapability");
|
|
351
|
+
}
|
|
352
|
+
options;
|
|
353
|
+
name = "checkpoint";
|
|
354
|
+
constructor(options) {
|
|
355
|
+
this.options = options;
|
|
356
|
+
}
|
|
357
|
+
apply(draft) {
|
|
358
|
+
if (this.options !== void 0 && this.options.storage !== "filesystem") {
|
|
359
|
+
console.warn(`[THEO_AGENT_CHECKPOINT_STORAGE_METADATA_ONLY] checkpoint({ storage: '${this.options.storage ?? "memory"}' }) does NOT resume across requests \u2014 only 'filesystem' selects the SDK's durable conversation store. Use checkpoint({ storage: 'filesystem' }) for cross-request resume.`);
|
|
314
360
|
}
|
|
315
|
-
setOnce(draft, "checkpoint", options,
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
var
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
361
|
+
setOnce(draft, "checkpoint", this.options, this.name);
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
var HumanInTheLoopCapability = class extends FieldCapability {
|
|
365
|
+
static {
|
|
366
|
+
__name(this, "HumanInTheLoopCapability");
|
|
367
|
+
}
|
|
368
|
+
name = "human-in-the-loop";
|
|
369
|
+
field = "hitl";
|
|
370
|
+
};
|
|
371
|
+
var SubAgentsCapability = class {
|
|
372
|
+
static {
|
|
373
|
+
__name(this, "SubAgentsCapability");
|
|
374
|
+
}
|
|
375
|
+
children;
|
|
376
|
+
name = "sub-agents";
|
|
377
|
+
constructor(children) {
|
|
378
|
+
this.children = children;
|
|
379
|
+
}
|
|
380
|
+
apply(draft) {
|
|
381
|
+
for (const [name, child] of Object.entries(this.children)) {
|
|
323
382
|
if (name in draft.agents && draft.agents[name] !== child) {
|
|
324
383
|
throw new ConfigurationError(`sub-agents: filho "${name}" declarado duas vezes com defini\xE7\xF5es diferentes`);
|
|
325
384
|
}
|
|
326
385
|
draft.agents[name] = child;
|
|
327
386
|
}
|
|
328
387
|
draft.provenance.push({
|
|
329
|
-
capability:
|
|
388
|
+
capability: this.name,
|
|
330
389
|
contributed: [
|
|
331
390
|
"agents"
|
|
332
391
|
]
|
|
333
392
|
});
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
var
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
var SkillsOptionsCapability = class {
|
|
396
|
+
static {
|
|
397
|
+
__name(this, "SkillsOptionsCapability");
|
|
398
|
+
}
|
|
399
|
+
options;
|
|
400
|
+
name = "skills";
|
|
401
|
+
constructor(options) {
|
|
402
|
+
this.options = options;
|
|
403
|
+
}
|
|
404
|
+
apply(draft) {
|
|
405
|
+
setOnce(draft, "skills", compileSkills(this.options), this.name);
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
var SettingSourcesCapability = class extends FieldCapability {
|
|
409
|
+
static {
|
|
410
|
+
__name(this, "SettingSourcesCapability");
|
|
411
|
+
}
|
|
412
|
+
name = "setting-sources";
|
|
413
|
+
field = "settingSources";
|
|
414
|
+
};
|
|
415
|
+
var PluginsCapability = class extends FieldCapability {
|
|
416
|
+
static {
|
|
417
|
+
__name(this, "PluginsCapability");
|
|
418
|
+
}
|
|
419
|
+
name = "plugins";
|
|
420
|
+
field = "plugins";
|
|
421
|
+
};
|
|
422
|
+
var RunContextCapability = class extends FieldCapability {
|
|
423
|
+
static {
|
|
424
|
+
__name(this, "RunContextCapability");
|
|
425
|
+
}
|
|
426
|
+
name = "run-context";
|
|
427
|
+
field = "runContext";
|
|
428
|
+
};
|
|
429
|
+
var SkillsResolverCapability = class extends FieldCapability {
|
|
430
|
+
static {
|
|
431
|
+
__name(this, "SkillsResolverCapability");
|
|
432
|
+
}
|
|
433
|
+
name = "skills-resolver";
|
|
434
|
+
field = "skillsResolver";
|
|
435
|
+
};
|
|
346
436
|
var AgentConfigCapability = class {
|
|
347
437
|
static {
|
|
348
438
|
__name(this, "AgentConfigCapability");
|
|
@@ -773,6 +863,7 @@ export {
|
|
|
773
863
|
AGENT_BRAND,
|
|
774
864
|
AcpClient,
|
|
775
865
|
AcpMessageDecoder,
|
|
866
|
+
AgentBuilder,
|
|
776
867
|
AgentConfigCapability,
|
|
777
868
|
AgentDefinitionError,
|
|
778
869
|
AgentRunner,
|
|
@@ -781,25 +872,39 @@ export {
|
|
|
781
872
|
CapabilityConflictError,
|
|
782
873
|
CapabilityPreset,
|
|
783
874
|
CapabilityRegistry,
|
|
875
|
+
CheckpointCapability,
|
|
784
876
|
ConfigurationError,
|
|
877
|
+
ContextWindowCapability,
|
|
878
|
+
ContextualTool,
|
|
785
879
|
CostBudgetExceededError,
|
|
786
880
|
DEFAULT_KEEP_TOKENS,
|
|
787
881
|
DEFAULT_MAX_ITERATIONS,
|
|
788
882
|
DelegationError,
|
|
883
|
+
FieldCapability,
|
|
789
884
|
GuardrailViolationError,
|
|
885
|
+
GuardrailsCapability,
|
|
886
|
+
HumanInTheLoopCapability,
|
|
790
887
|
MCP_PROTOCOL_VERSION,
|
|
791
888
|
MainLoopCapability,
|
|
889
|
+
McpServersCapability,
|
|
890
|
+
MemoryCapability,
|
|
792
891
|
ModelCapability,
|
|
892
|
+
PluginsCapability,
|
|
893
|
+
ProjectContextCapability,
|
|
894
|
+
RunContextCapability,
|
|
895
|
+
SettingSourcesCapability,
|
|
896
|
+
SkillsCapability,
|
|
897
|
+
SkillsOptionsCapability,
|
|
898
|
+
SkillsResolverCapability,
|
|
899
|
+
SubAgentsCapability,
|
|
793
900
|
ToolboxCapability,
|
|
794
901
|
ToolsCapability,
|
|
795
902
|
UnknownCapabilityError,
|
|
796
|
-
agent,
|
|
797
903
|
agentsPlugin,
|
|
798
904
|
applyCapabilities,
|
|
799
905
|
buildAgentCard,
|
|
800
906
|
buildMcpToolDescriptors,
|
|
801
907
|
buildModelSelection,
|
|
802
|
-
checkpoint,
|
|
803
908
|
compactionStrategyConfigSchema,
|
|
804
909
|
compileAgentDefinition,
|
|
805
910
|
compileAgentModule,
|
|
@@ -807,8 +912,6 @@ export {
|
|
|
807
912
|
compileProjectContext,
|
|
808
913
|
compileSkills,
|
|
809
914
|
compileTools,
|
|
810
|
-
contextWindow,
|
|
811
|
-
contextualTool,
|
|
812
915
|
costGuard,
|
|
813
916
|
createA2ATool,
|
|
814
917
|
createAgentExecutionContext,
|
|
@@ -826,8 +929,6 @@ export {
|
|
|
826
929
|
extractThinkTagStream,
|
|
827
930
|
generateAgentManifest,
|
|
828
931
|
generateAgentRoutes,
|
|
829
|
-
guardrails,
|
|
830
|
-
humanInTheLoop,
|
|
831
932
|
isAgentContext,
|
|
832
933
|
isAgentDefinition,
|
|
833
934
|
isApprovalRequired,
|
|
@@ -841,17 +942,13 @@ export {
|
|
|
841
942
|
loopStrategyConfigSchema,
|
|
842
943
|
mcpRegistry,
|
|
843
944
|
mcpServerInfo,
|
|
844
|
-
mcpServers,
|
|
845
945
|
mcpToolApprovals,
|
|
846
|
-
memory,
|
|
847
946
|
moderateOutputStream,
|
|
848
947
|
noopReflectionStrategy,
|
|
849
948
|
outputModeration,
|
|
850
949
|
parseConversationId,
|
|
851
950
|
piiDetector,
|
|
852
|
-
plugins,
|
|
853
951
|
presentUIMessageStream,
|
|
854
|
-
projectContext,
|
|
855
952
|
projectContextMetadataOnlyKnobs,
|
|
856
953
|
promptInjectionDetector,
|
|
857
954
|
reflectionStrategyConfigSchema,
|
|
@@ -859,18 +956,12 @@ export {
|
|
|
859
956
|
resolveEnabledSkills,
|
|
860
957
|
resolveLoopStrategy,
|
|
861
958
|
resolveMcpServers,
|
|
862
|
-
runContext,
|
|
863
959
|
runInputGuards,
|
|
864
960
|
runOutputGuards,
|
|
865
961
|
runWithApiErrorHandling,
|
|
866
962
|
setOnce,
|
|
867
|
-
settingSources,
|
|
868
|
-
skills,
|
|
869
|
-
skillsOptions,
|
|
870
|
-
skillsResolver,
|
|
871
963
|
streamAgentResponse,
|
|
872
964
|
streamAgentUIMessages,
|
|
873
|
-
subAgents,
|
|
874
965
|
toAgentFactory,
|
|
875
966
|
tokenBudgetCompactionStrategy,
|
|
876
967
|
translateSdkEvent,
|