@gajae-code/agent-core 0.12.6 → 0.12.8
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/CHANGELOG.md +4 -0
- package/dist/types/agent.d.ts +5 -0
- package/package.json +4 -4
- package/src/agent.ts +25 -2
package/CHANGELOG.md
CHANGED
package/dist/types/agent.d.ts
CHANGED
|
@@ -206,6 +206,11 @@ export declare class Agent {
|
|
|
206
206
|
};
|
|
207
207
|
/** Return the Agent-owned attempt scope authority for session record injection. */
|
|
208
208
|
getAttemptScopeAuthority(): import("./attempt-scope").AttemptScopeAuthority;
|
|
209
|
+
/**
|
|
210
|
+
* Observe each main-attempt scope synchronously, before any provider or
|
|
211
|
+
* extension-capable lifecycle work can begin.
|
|
212
|
+
*/
|
|
213
|
+
setMainAttemptScopeObserver(observer: ((scope: AttemptScope) => void) | undefined): void;
|
|
209
214
|
streamFn: StreamFn;
|
|
210
215
|
getApiKey?: (provider: string) => Promise<string | undefined> | string | undefined;
|
|
211
216
|
getAuthCredentialType?: (provider: string) => "api_key" | "oauth" | undefined;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@gajae-code/agent-core",
|
|
4
|
-
"version": "0.12.
|
|
4
|
+
"version": "0.12.8",
|
|
5
5
|
"description": "General-purpose agent with transport abstraction, state management, and attachment support",
|
|
6
6
|
"homepage": "https://gajae-code.com",
|
|
7
7
|
"author": "Yeachan-Heo and Gajae Code Contributors",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"fmt": "biome format --write ."
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@gajae-code/ai": "0.12.
|
|
36
|
-
"@gajae-code/natives": "0.12.
|
|
37
|
-
"@gajae-code/utils": "0.12.
|
|
35
|
+
"@gajae-code/ai": "0.12.8",
|
|
36
|
+
"@gajae-code/natives": "0.12.8",
|
|
37
|
+
"@gajae-code/utils": "0.12.8",
|
|
38
38
|
"@opentelemetry/api": "^1.9.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
package/src/agent.ts
CHANGED
|
@@ -344,7 +344,11 @@ export class Agent {
|
|
|
344
344
|
#listeners = new Set<(e: AgentEvent) => void>();
|
|
345
345
|
#abortController?: AbortController;
|
|
346
346
|
#convertToLlm: (messages: AgentMessage[]) => Message[] | Promise<Message[]>;
|
|
347
|
-
#transformContext?: (
|
|
347
|
+
#transformContext?: (
|
|
348
|
+
messages: AgentMessage[],
|
|
349
|
+
signal?: AbortSignal,
|
|
350
|
+
scope?: AttemptScope,
|
|
351
|
+
) => Promise<AgentMessage[]>;
|
|
348
352
|
#steeringQueue: AgentMessage[] = [];
|
|
349
353
|
#followUpQueue: AgentMessage[] = [];
|
|
350
354
|
#followUpForceOneAtATime = new WeakSet<AgentMessage>();
|
|
@@ -395,6 +399,7 @@ export class Agent {
|
|
|
395
399
|
#maintainContext?: AgentLoopConfig["maintainContext"];
|
|
396
400
|
#telemetry?: AgentLoopConfig["telemetry"];
|
|
397
401
|
#appendOnlyContext?: AppendOnlyContextManager;
|
|
402
|
+
#mainAttemptScopeObserver?: (scope: AttemptScope) => void;
|
|
398
403
|
|
|
399
404
|
get intentTracing(): boolean {
|
|
400
405
|
return this.#intentTracing;
|
|
@@ -419,6 +424,17 @@ export class Agent {
|
|
|
419
424
|
getAttemptScopeAuthority() {
|
|
420
425
|
return this.#attemptAuthority;
|
|
421
426
|
}
|
|
427
|
+
/**
|
|
428
|
+
* Observe each main-attempt scope synchronously, before any provider or
|
|
429
|
+
* extension-capable lifecycle work can begin.
|
|
430
|
+
*/
|
|
431
|
+
setMainAttemptScopeObserver(observer: ((scope: AttemptScope) => void) | undefined): void {
|
|
432
|
+
this.#mainAttemptScopeObserver = observer;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
#observeMainAttemptScope(scope: AttemptScope): void {
|
|
436
|
+
this.#mainAttemptScopeObserver?.(scope);
|
|
437
|
+
}
|
|
422
438
|
|
|
423
439
|
streamFn: StreamFn;
|
|
424
440
|
getApiKey?: (provider: string) => Promise<string | undefined> | string | undefined;
|
|
@@ -1439,6 +1455,7 @@ export class Agent {
|
|
|
1439
1455
|
}
|
|
1440
1456
|
const logicalRunId = managedLogicalRunOwner ?? runId;
|
|
1441
1457
|
const scope = this.#attemptAuthority.mintMain();
|
|
1458
|
+
this.#observeMainAttemptScope(scope);
|
|
1442
1459
|
const handle: AttemptRunHandle = { logicalRunId, scope };
|
|
1443
1460
|
this.#runHandles.set(logicalRunId, handle);
|
|
1444
1461
|
options?.onRunAccepted?.(handle);
|
|
@@ -1547,7 +1564,13 @@ export class Agent {
|
|
|
1547
1564
|
preferWebsockets: this.#preferWebsockets,
|
|
1548
1565
|
convertToLlm: this.#convertToLlm,
|
|
1549
1566
|
transformContext: this.#transformContext,
|
|
1550
|
-
attemptMinter: {
|
|
1567
|
+
attemptMinter: {
|
|
1568
|
+
mint: () => {
|
|
1569
|
+
const scope = this.#attemptAuthority.mintMain();
|
|
1570
|
+
this.#observeMainAttemptScope(scope);
|
|
1571
|
+
return scope;
|
|
1572
|
+
},
|
|
1573
|
+
},
|
|
1551
1574
|
initialScope: scope,
|
|
1552
1575
|
onPayload: this.#onPayload,
|
|
1553
1576
|
onResponse: this.#onResponse,
|