@agentuity/runtime 0.0.48 → 0.0.50
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/_context.d.ts +6 -1
- package/dist/_context.d.ts.map +1 -1
- package/dist/_server.d.ts.map +1 -1
- package/dist/_services.d.ts.map +1 -1
- package/dist/_tokens.d.ts +3 -0
- package/dist/_tokens.d.ts.map +1 -0
- package/dist/agent.d.ts +9 -8
- package/dist/agent.d.ts.map +1 -1
- package/dist/eval.d.ts +5 -1
- package/dist/eval.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/services/local/keyvalue.d.ts +8 -1
- package/dist/services/local/keyvalue.d.ts.map +1 -1
- package/dist/services/local/objectstore.d.ts +9 -1
- package/dist/services/local/objectstore.d.ts.map +1 -1
- package/dist/workbench.d.ts +3 -0
- package/dist/workbench.d.ts.map +1 -0
- package/package.json +8 -5
- package/src/_context.ts +29 -5
- package/src/_server.ts +16 -4
- package/src/_services.ts +130 -120
- package/src/_tokens.ts +115 -0
- package/src/agent.ts +51 -38
- package/src/eval.ts +5 -1
- package/src/index.ts +1 -0
- package/src/router.ts +4 -4
- package/src/services/local/keyvalue.ts +33 -0
- package/src/services/local/objectstore.ts +25 -0
- package/src/workbench.ts +40 -0
package/dist/_context.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import type { Context as HonoContext } from 'hono';
|
|
2
3
|
import type { Tracer } from '@opentelemetry/api';
|
|
3
4
|
import type { KeyValueStorage, ObjectStorage, StreamStorage, VectorStorage } from '@agentuity/core';
|
|
4
5
|
import type { AgentContext, AgentName } from './agent';
|
|
@@ -37,7 +38,11 @@ export declare class RequestAgentContext<TAgentMap, TAgent> implements AgentCont
|
|
|
37
38
|
waitUntil(callback: Promise<void> | (() => void | Promise<void>)): void;
|
|
38
39
|
}
|
|
39
40
|
export declare const inAgentContext: () => boolean;
|
|
41
|
+
export declare const inHTTPContext: () => boolean;
|
|
40
42
|
export declare const getAgentContext: () => AgentContext;
|
|
41
|
-
export declare const
|
|
43
|
+
export declare const getHTTPContext: () => HonoContext;
|
|
44
|
+
export declare const getAgentAsyncLocalStorage: () => AsyncLocalStorage<AgentContext>;
|
|
45
|
+
export declare const getHTTPAsyncLocalStorage: () => AsyncLocalStorage<HonoContext<any, any, {}>>;
|
|
42
46
|
export declare const runInAgentContext: <TAgentMap, TAgent>(ctxObject: Record<string, unknown>, args: RequestAgentContextArgs<TAgentMap, TAgent>, next: () => Promise<void>) => Promise<void>;
|
|
47
|
+
export declare const runInHTTPContext: <HonoContext>(ctx: HonoContext, next: () => Promise<void>) => Promise<void>;
|
|
43
48
|
//# sourceMappingURL=_context.d.ts.map
|
package/dist/_context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_context.d.ts","sourceRoot":"","sources":["../src/_context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACpG,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,gBAAgB,MAAM,cAAc,CAAC;AAEjD,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEjD,MAAM,WAAW,uBAAuB,CAAC,SAAS,EAAE,MAAM;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,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E,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"_server.d.ts","sourceRoot":"","sources":["../src/_server.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,KAAK,MAAM,EAIX,MAAM,oBAAoB,CAAC;AAG5B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAInE,OAAO,EAAE,IAAI,EAAE,KAAK,OAAO,IAAI,WAAW,EAAE,MAAM,MAAM,CAAC;AAEzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAIjD,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAG9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAuBvC,wBAAgB,SAAS,wCAExB;AAED,wBAAgB,SAAS,4DAExB;AAED,wBAAgB,SAAS,kBAExB;AAED,wBAAgB,SAAS,kBAExB;AAcD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,aAAa,QAExD;AA6CD,wBAAgB,cAAc,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,GACvC,WAAW,CAAC;IAAE,SAAS,EAAE,gBAAgB,CAAA;CAAE,CAAC,CACnE;AAED,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,GAAG,EAAE,QAAQ,IAAI,CAAC,CAAC,CAAC,EAAE,SAAS,SAAS,iCAiP9E,CAAC"}
|
package/dist/_services.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_services.d.ts","sourceRoot":"","sources":["../src/_services.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"_services.d.ts","sourceRoot":"","sources":["../src/_services.ts"],"names":[],"mappings":"AACA,OAAO,EAaN,KAAK,MAAM,EACX,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,MAAM,iBAAiB,CAAC;AAiBzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAGN,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,MAAM,WAAW,CAAC;AAuJnB,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,MAAM;;;;EA6EpF;AAED,wBAAgB,iBAAiB,IAAI,cAAc,CAElD;AAED,wBAAgB,kBAAkB,IAAI,eAAe,CAEpD;AAGD,wBAAgB,cAAc,IAAI,GAAG,GAAG,IAAI,CAE3C;AAED,wBAAgB,uBAAuB,yBAEtC;AAED,wBAAgB,uBAAuB,yBAEtC;AAGD,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,GAAG,EAAE,aAAa,UAAQ,QAyC7D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_tokens.d.ts","sourceRoot":"","sources":["../src/_tokens.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,aAAa,uBAAuB,CAAC;AAyGlD,MAAM,CAAC,OAAO,UAAU,QAAQ,SAE/B"}
|
package/dist/agent.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { KeyValueStorage, ObjectStorage, StandardSchemaV1, StreamStorage, VectorStorage } from '@agentuity/core';
|
|
2
|
-
import type
|
|
2
|
+
import { type Tracer } from '@opentelemetry/api';
|
|
3
3
|
import type { Context, MiddlewareHandler } from 'hono';
|
|
4
4
|
import type { Logger } from './logger';
|
|
5
5
|
import type { Eval, EvalFunction, ExternalEvalMetadata } from './eval';
|
|
@@ -25,15 +25,15 @@ export interface AgentContext {
|
|
|
25
25
|
}
|
|
26
26
|
type InternalAgentMetadata = {
|
|
27
27
|
/**
|
|
28
|
-
* the unique identifier for this agent and
|
|
28
|
+
* the unique identifier for this project, agent and deployment.
|
|
29
29
|
*/
|
|
30
30
|
id: string;
|
|
31
31
|
/**
|
|
32
|
-
* the
|
|
32
|
+
* the unique identifier for this project and agent across multiple deployments.
|
|
33
33
|
*/
|
|
34
34
|
identifier: string;
|
|
35
35
|
/**
|
|
36
|
-
* the relative path to the agent from the root project directory
|
|
36
|
+
* the relative path to the agent from the root project directory.
|
|
37
37
|
*/
|
|
38
38
|
filename: string;
|
|
39
39
|
/**
|
|
@@ -43,13 +43,13 @@ type InternalAgentMetadata = {
|
|
|
43
43
|
};
|
|
44
44
|
type ExternalAgentMetadata = {
|
|
45
45
|
/**
|
|
46
|
-
* the human readable name for the agent
|
|
46
|
+
* the human readable name for the agent.
|
|
47
47
|
*/
|
|
48
48
|
name: string;
|
|
49
49
|
/**
|
|
50
|
-
* the human readable description for the agent
|
|
50
|
+
* the human readable description for the agent
|
|
51
51
|
*/
|
|
52
|
-
description
|
|
52
|
+
description?: string;
|
|
53
53
|
};
|
|
54
54
|
type AgentMetadata = InternalAgentMetadata & ExternalAgentMetadata;
|
|
55
55
|
type CreateEvalMethod<TInput extends StandardSchemaV1 | undefined = any, TOutput extends StandardSchemaV1 | undefined = any> = (config: {
|
|
@@ -103,7 +103,7 @@ export declare function createAgent<TInput extends StandardSchemaV1 | undefined
|
|
|
103
103
|
output?: TOutput;
|
|
104
104
|
stream?: TStream;
|
|
105
105
|
};
|
|
106
|
-
metadata
|
|
106
|
+
metadata: ExternalAgentMetadata;
|
|
107
107
|
handler: TInput extends StandardSchemaV1 ? TStream extends true ? TOutput extends StandardSchemaV1 ? (c: AgentContext, input: StandardSchemaV1.InferOutput<TInput>) => Promise<ReadableStream<StandardSchemaV1.InferOutput<TOutput>>> | ReadableStream<StandardSchemaV1.InferOutput<TOutput>> : (c: AgentContext, input: StandardSchemaV1.InferOutput<TInput>) => Promise<ReadableStream<unknown>> | ReadableStream<unknown> : TOutput extends StandardSchemaV1 ? (c: AgentContext, input: StandardSchemaV1.InferOutput<TInput>) => Promise<StandardSchemaV1.InferOutput<TOutput>> | StandardSchemaV1.InferOutput<TOutput> : (c: AgentContext, input: StandardSchemaV1.InferOutput<TInput>) => Promise<void> | void : TStream extends true ? TOutput extends StandardSchemaV1 ? (c: AgentContext) => Promise<ReadableStream<StandardSchemaV1.InferOutput<TOutput>>> | ReadableStream<StandardSchemaV1.InferOutput<TOutput>> : (c: AgentContext) => Promise<ReadableStream<unknown>> | ReadableStream<unknown> : TOutput extends StandardSchemaV1 ? (c: AgentContext) => Promise<StandardSchemaV1.InferOutput<TOutput>> | StandardSchemaV1.InferOutput<TOutput> : (c: AgentContext) => Promise<void> | void;
|
|
108
108
|
}): Agent<TInput, TOutput, TStream>;
|
|
109
109
|
/**
|
|
@@ -111,5 +111,6 @@ export declare function createAgent<TInput extends StandardSchemaV1 | undefined
|
|
|
111
111
|
*/
|
|
112
112
|
export declare const populateAgentsRegistry: (ctx: Context) => any;
|
|
113
113
|
export declare const createAgentMiddleware: (agentName: AgentName) => MiddlewareHandler;
|
|
114
|
+
export declare const getAgents: () => Map<string, Agent<any, any, false>>;
|
|
114
115
|
export {};
|
|
115
116
|
//# sourceMappingURL=agent.d.ts.map
|
package/dist/agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAA2B,KAAK,MAAM,EAAS,MAAM,oBAAoB,CAAC;AACjF,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAEvD,OAAO,KAAK,EAAE,MAAM,EAAE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,GAAG,IAAI,CAAC;CAC/C,GAAG,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAgblC;AA8DD;;GAEG;AACH,eAAO,MAAM,sBAAsB,GAAI,KAAK,OAAO,KAAG,GA4CrD,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,WAAW,SAAS,KAAG,iBAmD5D,CAAC;AAEF,eAAO,MAAM,SAAS,2CAAe,CAAC"}
|
package/dist/eval.d.ts
CHANGED
|
@@ -23,16 +23,20 @@ export type EvalRunResult = EvalRunResultBinary | EvalRunResultScore | EvalRunRe
|
|
|
23
23
|
export type CreateEvalRunRequest = {
|
|
24
24
|
projectId: string;
|
|
25
25
|
sessionId: string;
|
|
26
|
-
spanId: string;
|
|
27
26
|
result: EvalRunResult;
|
|
28
27
|
evalId: string;
|
|
29
28
|
promptHash?: string;
|
|
29
|
+
deploymentId?: string;
|
|
30
30
|
};
|
|
31
31
|
type InternalEvalMetadata = {
|
|
32
32
|
/**
|
|
33
33
|
* the unique identifier for this eval and project
|
|
34
34
|
*/
|
|
35
35
|
id: string;
|
|
36
|
+
/**
|
|
37
|
+
* the unique identifier for this project and eval across multiple deployments.
|
|
38
|
+
*/
|
|
39
|
+
evalId: string;
|
|
36
40
|
/**
|
|
37
41
|
* the folder name for the eval
|
|
38
42
|
*/
|
package/dist/eval.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eval.d.ts","sourceRoot":"","sources":["../src/eval.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG5C,MAAM,MAAM,WAAW,GAAG,YAAY,CAAC;AAEvC,MAAM,MAAM,qBAAqB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC;IAEf,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACnB,CAAC;AAEF,MAA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,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC/C,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,YAAY,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC/C,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import type { Database } from 'bun:sqlite';
|
|
2
|
-
import type { KeyValueStorage, DataResult, KeyValueStorageSetParams } from '@agentuity/core';
|
|
2
|
+
import type { KeyValueStorage, DataResult, KeyValueStorageSetParams, KeyValueStats, KeyValueItemWithMetadata } from '@agentuity/core';
|
|
3
3
|
export declare class LocalKeyValueStorage implements KeyValueStorage {
|
|
4
4
|
#private;
|
|
5
5
|
constructor(db: Database, projectPath: string);
|
|
6
6
|
get<T>(name: string, key: string): Promise<DataResult<T>>;
|
|
7
7
|
set<T = unknown>(name: string, key: string, value: T, params?: KeyValueStorageSetParams): Promise<void>;
|
|
8
8
|
delete(name: string, key: string): Promise<void>;
|
|
9
|
+
getStats(_name: string): Promise<KeyValueStats>;
|
|
10
|
+
getAllStats(): Promise<Record<string, KeyValueStats>>;
|
|
11
|
+
getNamespaces(): Promise<string[]>;
|
|
12
|
+
search<T = unknown>(_name: string, _keyword: string): Promise<Record<string, KeyValueItemWithMetadata<T>>>;
|
|
13
|
+
getKeys(_name: string): Promise<string[]>;
|
|
14
|
+
deleteNamespace(_name: string): Promise<void>;
|
|
15
|
+
createNamespace(_name: string): Promise<void>;
|
|
9
16
|
}
|
|
10
17
|
//# sourceMappingURL=keyvalue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyvalue.d.ts","sourceRoot":"","sources":["../../../src/services/local/keyvalue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EACX,eAAe,EACf,UAAU,EAEV,wBAAwB,EACxB,MAAM,iBAAiB,CAAC;AAGzB,qBAAa,oBAAqB,YAAW,eAAe;;gBAI/C,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM;IAKvC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAyCzD,GAAG,CAAC,CAAC,GAAG,OAAO,EACpB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,CAAC,EACR,MAAM,CAAC,EAAE,wBAAwB,GAC/B,OAAO,CAAC,IAAI,CAAC;IA6CV,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"keyvalue.d.ts","sourceRoot":"","sources":["../../../src/services/local/keyvalue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EACX,eAAe,EACf,UAAU,EAEV,wBAAwB,EACxB,aAAa,EACb,wBAAwB,EACxB,MAAM,iBAAiB,CAAC;AAGzB,qBAAa,oBAAqB,YAAW,eAAe;;gBAI/C,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM;IAKvC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAyCzD,GAAG,CAAC,CAAC,GAAG,OAAO,EACpB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,CAAC,EACR,MAAM,CAAC,EAAE,wBAAwB,GAC/B,OAAO,CAAC,IAAI,CAAC;IA6CV,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAShD,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAI/C,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAIrD,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIlC,MAAM,CAAC,CAAC,GAAG,OAAO,EACvB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC;IAIjD,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAIzC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGnD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Database } from 'bun:sqlite';
|
|
2
|
-
import type { ObjectStorage, ObjectResult, ObjectStorePutParams, CreatePublicURLParams } from '@agentuity/core';
|
|
2
|
+
import type { ObjectStorage, ObjectResult, ObjectStorePutParams, CreatePublicURLParams, BucketInfo, ObjectInfo } from '@agentuity/core';
|
|
3
3
|
export declare class LocalObjectStorage implements ObjectStorage {
|
|
4
4
|
#private;
|
|
5
5
|
constructor(db: Database, projectPath: string, serverUrl: string);
|
|
@@ -7,5 +7,13 @@ export declare class LocalObjectStorage implements ObjectStorage {
|
|
|
7
7
|
put(bucket: string, key: string, data: Uint8Array | ArrayBuffer | ReadableStream, params?: ObjectStorePutParams): Promise<void>;
|
|
8
8
|
delete(bucket: string, key: string): Promise<boolean>;
|
|
9
9
|
createPublicURL(bucket: string, key: string, _params?: CreatePublicURLParams): Promise<string>;
|
|
10
|
+
listBuckets(): Promise<BucketInfo[]>;
|
|
11
|
+
listKeys(_bucket: string): Promise<ObjectInfo[]>;
|
|
12
|
+
listObjects(_bucket: string, _options?: {
|
|
13
|
+
prefix?: string;
|
|
14
|
+
limit?: number;
|
|
15
|
+
}): Promise<ObjectInfo[]>;
|
|
16
|
+
headObject(_bucket: string, _key: string): Promise<ObjectInfo>;
|
|
17
|
+
deleteBucket(_bucket: string): Promise<boolean>;
|
|
10
18
|
}
|
|
11
19
|
//# sourceMappingURL=objectstore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objectstore.d.ts","sourceRoot":"","sources":["../../../src/services/local/objectstore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EACX,aAAa,EACb,YAAY,EAEZ,oBAAoB,EACpB,qBAAqB,EACrB,MAAM,iBAAiB,CAAC;AAGzB,qBAAa,kBAAmB,YAAW,aAAa;;gBAK3C,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAM1D,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IA2BvD,GAAG,CACR,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,UAAU,GAAG,WAAW,GAAG,cAAc,EAC/C,MAAM,CAAC,EAAE,oBAAoB,GAC3B,OAAO,CAAC,IAAI,C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,EACf,QAAQ,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAC5C,OAAO,CAAC,UAAU,EAAE,CAAC;IAIlB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAI9D,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAGrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workbench.d.ts","sourceRoot":"","sources":["../src/workbench.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAIpC,eAAO,MAAM,4BAA4B,QAAO,OAkC/C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentuity/runtime",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.50",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"author": "Agentuity employees and contributors",
|
|
6
6
|
"type": "module",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"prepublishOnly": "bun run clean && bun run build"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@agentuity/core": "0.0.
|
|
29
|
-
"@agentuity/server": "0.0.
|
|
28
|
+
"@agentuity/core": "0.0.50",
|
|
29
|
+
"@agentuity/server": "0.0.50",
|
|
30
30
|
"@opentelemetry/api": "^1.9.0",
|
|
31
31
|
"@opentelemetry/api-logs": "^0.207.0",
|
|
32
32
|
"@opentelemetry/auto-instrumentations-node": "^0.66.0",
|
|
@@ -42,14 +42,17 @@
|
|
|
42
42
|
"@opentelemetry/sdk-node": "^0.207.0",
|
|
43
43
|
"@opentelemetry/sdk-trace-base": "^2.2.0",
|
|
44
44
|
"@opentelemetry/semantic-conventions": "^1.37.0",
|
|
45
|
+
"@traceloop/ai-semantic-conventions": "0.19.0",
|
|
45
46
|
"@traceloop/node-server-sdk": "^0.19.1",
|
|
46
|
-
"mailparser": "^3.7.1"
|
|
47
|
-
"@types/mailparser": "^3.4.6"
|
|
47
|
+
"mailparser": "^3.7.1"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"hono": "^4.10.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
+
"@types/bun": "latest",
|
|
54
|
+
"bun-types": "latest",
|
|
55
|
+
"@types/mailparser": "^3.4.6",
|
|
53
56
|
"@types/react": "^19.2.2",
|
|
54
57
|
"@types/react-dom": "^19.2.2",
|
|
55
58
|
"react": "^19.2.0",
|
package/src/_context.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import type { Context as HonoContext } from 'hono';
|
|
2
3
|
import type { Tracer } from '@opentelemetry/api';
|
|
3
4
|
import type { KeyValueStorage, ObjectStorage, StreamStorage, VectorStorage } from '@agentuity/core';
|
|
4
5
|
import type { AgentContext, AgentName } from './agent';
|
|
@@ -57,22 +58,37 @@ export class RequestAgentContext<TAgentMap, TAgent> implements AgentContext {
|
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
const
|
|
61
|
+
const agentAsyncLocalStorage = new AsyncLocalStorage<AgentContext>();
|
|
62
|
+
const httpAsyncLocalStorage = new AsyncLocalStorage<HonoContext>();
|
|
61
63
|
|
|
62
64
|
export const inAgentContext = (): boolean => {
|
|
63
|
-
const context =
|
|
65
|
+
const context = agentAsyncLocalStorage.getStore();
|
|
66
|
+
return !!context;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const inHTTPContext = (): boolean => {
|
|
70
|
+
const context = httpAsyncLocalStorage.getStore();
|
|
64
71
|
return !!context;
|
|
65
72
|
};
|
|
66
73
|
|
|
67
74
|
export const getAgentContext = (): AgentContext => {
|
|
68
|
-
const context =
|
|
75
|
+
const context = agentAsyncLocalStorage.getStore();
|
|
69
76
|
if (!context) {
|
|
70
77
|
throw new Error('AgentContext is not available');
|
|
71
78
|
}
|
|
72
79
|
return context;
|
|
73
80
|
};
|
|
74
81
|
|
|
75
|
-
export const
|
|
82
|
+
export const getHTTPContext = (): HonoContext => {
|
|
83
|
+
const context = httpAsyncLocalStorage.getStore();
|
|
84
|
+
if (!context) {
|
|
85
|
+
throw new Error('HTTPContext is not available');
|
|
86
|
+
}
|
|
87
|
+
return context;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const getAgentAsyncLocalStorage = () => agentAsyncLocalStorage;
|
|
91
|
+
export const getHTTPAsyncLocalStorage = () => httpAsyncLocalStorage;
|
|
76
92
|
|
|
77
93
|
export const runInAgentContext = <TAgentMap, TAgent>(
|
|
78
94
|
ctxObject: Record<string, unknown>,
|
|
@@ -88,8 +104,16 @@ export const runInAgentContext = <TAgentMap, TAgent>(
|
|
|
88
104
|
for (const k of ['waitUntil']) {
|
|
89
105
|
ctxObject[k] = _ctx[k];
|
|
90
106
|
}
|
|
91
|
-
return
|
|
107
|
+
return agentAsyncLocalStorage.run(ctx, async () => {
|
|
92
108
|
const result = await next();
|
|
93
109
|
return result;
|
|
94
110
|
});
|
|
95
111
|
};
|
|
112
|
+
|
|
113
|
+
export const runInHTTPContext = async <HonoContext>(
|
|
114
|
+
ctx: HonoContext,
|
|
115
|
+
next: () => Promise<void>
|
|
116
|
+
) => {
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
118
|
+
return httpAsyncLocalStorage.run(ctx as any, next);
|
|
119
|
+
};
|
package/src/_server.ts
CHANGED
|
@@ -26,7 +26,7 @@ import { register } from './otel/config';
|
|
|
26
26
|
import type { Logger } from './logger';
|
|
27
27
|
import { isIdle } from './_idle';
|
|
28
28
|
import * as runtimeConfig from './_config';
|
|
29
|
-
import { inAgentContext, getAgentContext } from './_context';
|
|
29
|
+
import { inAgentContext, getAgentContext, runInHTTPContext } from './_context';
|
|
30
30
|
import {
|
|
31
31
|
createServices,
|
|
32
32
|
getThreadProvider,
|
|
@@ -35,6 +35,9 @@ import {
|
|
|
35
35
|
} from './_services';
|
|
36
36
|
import { generateId } from './session';
|
|
37
37
|
import WaitUntilHandler from './_waituntil';
|
|
38
|
+
import registerTokenProcessor, { TOKENS_HEADER } from './_tokens';
|
|
39
|
+
|
|
40
|
+
const SESSION_HEADER = 'x-session-id';
|
|
38
41
|
|
|
39
42
|
let globalServerInstance: Bun.Server<BunWebSocketData> | null = null;
|
|
40
43
|
|
|
@@ -99,6 +102,8 @@ function registerAgentuitySpanProcessor() {
|
|
|
99
102
|
const agentCtx = getAgentContext();
|
|
100
103
|
if (agentCtx.current?.metadata) {
|
|
101
104
|
attrs['@agentuity/agentId'] = agentCtx.current.metadata.id;
|
|
105
|
+
attrs['@agentuity/agentIdentifier'] = agentCtx.current.metadata.agentId;
|
|
106
|
+
attrs['@agentuity/agentDescription'] = agentCtx.current.metadata.description;
|
|
102
107
|
attrs['@agentuity/agentName'] = agentCtx.current.metadata.name;
|
|
103
108
|
}
|
|
104
109
|
}
|
|
@@ -106,7 +111,7 @@ function registerAgentuitySpanProcessor() {
|
|
|
106
111
|
}
|
|
107
112
|
|
|
108
113
|
onEnd(_span: Span) {
|
|
109
|
-
|
|
114
|
+
return;
|
|
110
115
|
}
|
|
111
116
|
|
|
112
117
|
forceFlush() {
|
|
@@ -136,6 +141,7 @@ export const createServer = <E extends Env>(router: Hono<E>, config?: AppConfig)
|
|
|
136
141
|
|
|
137
142
|
// this must come before registering any otel stuff
|
|
138
143
|
registerAgentuitySpanProcessor();
|
|
144
|
+
registerTokenProcessor();
|
|
139
145
|
|
|
140
146
|
// Create the telemetry and logger
|
|
141
147
|
const otel = register({ processors: spanProcessors, logLevel: logLevel as LogLevel });
|
|
@@ -211,7 +217,7 @@ export const createServer = <E extends Env>(router: Hono<E>, config?: AppConfig)
|
|
|
211
217
|
otel.logger.debug('%s %s started', c.req.method, c.req.path);
|
|
212
218
|
}
|
|
213
219
|
|
|
214
|
-
await next
|
|
220
|
+
await runInHTTPContext(c, next);
|
|
215
221
|
|
|
216
222
|
// Don't log completion for websocket upgrades - they stay open
|
|
217
223
|
if (!skipLogging && !isWebSocket) {
|
|
@@ -238,7 +244,7 @@ export const createServer = <E extends Env>(router: Hono<E>, config?: AppConfig)
|
|
|
238
244
|
'X-Requested-With',
|
|
239
245
|
],
|
|
240
246
|
allowMethods: ['POST', 'GET', 'OPTIONS', 'HEAD', 'PUT', 'DELETE', 'PATCH'],
|
|
241
|
-
exposeHeaders: ['Content-Length'],
|
|
247
|
+
exposeHeaders: ['Content-Length', TOKENS_HEADER, SESSION_HEADER, 'x-deployment'],
|
|
242
248
|
maxAge: 600,
|
|
243
249
|
credentials: true,
|
|
244
250
|
...(config?.cors ?? {}), // allow the app config to override
|
|
@@ -553,6 +559,12 @@ const otelMiddleware = createMiddleware<Env>(async (c, next) => {
|
|
|
553
559
|
for (const key of Object.keys(headers)) {
|
|
554
560
|
c.header(key, headers[key]);
|
|
555
561
|
}
|
|
562
|
+
// add session and deployment headers
|
|
563
|
+
const traceId = sctx?.traceId || sessionId.replace(/^sess_/, '');
|
|
564
|
+
c.header(SESSION_HEADER, `sess_${traceId}`);
|
|
565
|
+
if (deploymentId) {
|
|
566
|
+
c.header('x-deployment', deploymentId);
|
|
567
|
+
}
|
|
556
568
|
if (!hasPendingWaits) {
|
|
557
569
|
try {
|
|
558
570
|
await sessionProvider.save(session);
|
package/src/_services.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
ObjectStorageService,
|
|
5
5
|
StreamStorageService,
|
|
6
6
|
VectorStorageService,
|
|
7
|
+
type FetchAdapter,
|
|
7
8
|
type KeyValueStorage,
|
|
8
9
|
type ObjectStorage,
|
|
9
10
|
type StreamStorage,
|
|
@@ -15,21 +16,21 @@ import {
|
|
|
15
16
|
type SessionEventProvider,
|
|
16
17
|
type EvalRunEventProvider,
|
|
17
18
|
} from '@agentuity/core';
|
|
18
|
-
import {
|
|
19
|
+
import { APIClient, createServerFetchAdapter, getServiceUrls } from '@agentuity/server';
|
|
19
20
|
import {
|
|
20
21
|
CompositeSessionEventProvider,
|
|
21
22
|
LocalSessionEventProvider,
|
|
22
23
|
JSONSessionEventProvider,
|
|
23
|
-
|
|
24
|
+
HTTPSessionEventProvider,
|
|
24
25
|
} from './services/session';
|
|
25
26
|
import {
|
|
26
27
|
CompositeEvalRunEventProvider,
|
|
27
28
|
LocalEvalRunEventProvider,
|
|
28
29
|
JSONEvalRunEventProvider,
|
|
29
|
-
|
|
30
|
+
HTTPEvalRunEventProvider,
|
|
30
31
|
} from './services/evalrun';
|
|
31
32
|
import { injectTraceContextToHeaders } from './otel/http';
|
|
32
|
-
import {
|
|
33
|
+
import { getTracer } from './_server';
|
|
33
34
|
import { getSDKVersion, isAuthenticated, isProduction } from './_config';
|
|
34
35
|
import type { AppConfig } from './app';
|
|
35
36
|
import {
|
|
@@ -56,119 +57,125 @@ const kvBaseUrl = serviceUrls.keyvalue;
|
|
|
56
57
|
const streamBaseUrl = serviceUrls.stream;
|
|
57
58
|
const vectorBaseUrl = serviceUrls.vector;
|
|
58
59
|
const objectBaseUrl = serviceUrls.objectstore;
|
|
59
|
-
|
|
60
|
+
const catalystBaseUrl = serviceUrls.catalyst;
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const span = tracer.startSpan(
|
|
75
|
-
options.telemetry.name,
|
|
76
|
-
{ attributes: options.telemetry.attributes, kind: SpanKind.CLIENT },
|
|
77
|
-
currentContext
|
|
78
|
-
);
|
|
79
|
-
const spanContext = trace.setSpan(currentContext, span);
|
|
80
|
-
try {
|
|
81
|
-
await context.with(spanContext, callback);
|
|
82
|
-
span.setStatus({ code: SpanStatusCode.OK });
|
|
83
|
-
} catch (err) {
|
|
84
|
-
const e = err as Error;
|
|
85
|
-
span.recordException(e);
|
|
86
|
-
span.setStatus({ code: SpanStatusCode.ERROR, message: e?.message ?? String(err) });
|
|
87
|
-
throw err;
|
|
88
|
-
} finally {
|
|
89
|
-
span.end();
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
onAfter: async (url, options, result, err) => {
|
|
93
|
-
getLogger()?.debug('after request: %s (%d) => %s', url, result.response.status, err);
|
|
94
|
-
if (err) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const span = trace.getSpan(context.active());
|
|
98
|
-
switch (options.telemetry?.name) {
|
|
99
|
-
case 'agentuity.keyvalue.get': {
|
|
100
|
-
if (result.response.status === 404) {
|
|
101
|
-
span?.addEvent('miss');
|
|
102
|
-
} else if (result.response.ok) {
|
|
103
|
-
span?.addEvent('hit');
|
|
104
|
-
}
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
case 'agentuity.stream.create': {
|
|
108
|
-
if (result.response.ok) {
|
|
109
|
-
const res = result.data as { id: string };
|
|
110
|
-
span?.setAttributes({
|
|
111
|
-
'stream.id': res.id,
|
|
112
|
-
'stream.url': `${streamBaseUrl}/${res.id}`,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
case 'agentuity.stream.list': {
|
|
118
|
-
const response = result.data as ListStreamsResponse;
|
|
119
|
-
if (response && span) {
|
|
120
|
-
span.setAttributes({
|
|
121
|
-
'stream.count': response.streams.length,
|
|
122
|
-
'stream.total': response.total,
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
case 'agentuity.vector.upsert': {
|
|
128
|
-
if (result.response.ok) {
|
|
129
|
-
const data = result.data as VectorUpsertResult[];
|
|
130
|
-
span?.setAttributes({
|
|
131
|
-
'vector.count': data.length,
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
case 'agentuity.vector.search': {
|
|
137
|
-
if (result.response.ok) {
|
|
138
|
-
const data = result.data as VectorSearchResult[];
|
|
139
|
-
span?.setAttributes({
|
|
140
|
-
'vector.results': data.length,
|
|
141
|
-
});
|
|
62
|
+
let adapter: FetchAdapter;
|
|
63
|
+
|
|
64
|
+
const createFetchAdapter = (logger: Logger) =>
|
|
65
|
+
createServerFetchAdapter(
|
|
66
|
+
{
|
|
67
|
+
headers: {
|
|
68
|
+
Authorization: bearerKey,
|
|
69
|
+
'User-Agent': userAgent,
|
|
70
|
+
},
|
|
71
|
+
onBefore: async (url, options, callback) => {
|
|
72
|
+
logger.debug('before request: %s with options: %s', url, options);
|
|
73
|
+
if (!options.telemetry) {
|
|
74
|
+
return callback();
|
|
142
75
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
76
|
+
options.headers = { ...options.headers, ...injectTraceContextToHeaders() };
|
|
77
|
+
const tracer = getTracer() ?? trace.getTracer('agentuity');
|
|
78
|
+
const currentContext = context.active();
|
|
79
|
+
const span = tracer.startSpan(
|
|
80
|
+
options.telemetry.name,
|
|
81
|
+
{ attributes: options.telemetry.attributes, kind: SpanKind.CLIENT },
|
|
82
|
+
currentContext
|
|
83
|
+
);
|
|
84
|
+
const spanContext = trace.setSpan(currentContext, span);
|
|
85
|
+
try {
|
|
86
|
+
await context.with(spanContext, callback);
|
|
87
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
88
|
+
} catch (err) {
|
|
89
|
+
const e = err as Error;
|
|
90
|
+
span.recordException(e);
|
|
91
|
+
span.setStatus({ code: SpanStatusCode.ERROR, message: e?.message ?? String(err) });
|
|
92
|
+
throw err;
|
|
93
|
+
} finally {
|
|
94
|
+
span.end();
|
|
150
95
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (
|
|
155
|
-
|
|
156
|
-
} else if (result.response.ok) {
|
|
157
|
-
span?.addEvent('hit');
|
|
96
|
+
},
|
|
97
|
+
onAfter: async (url, options, result, err) => {
|
|
98
|
+
logger.debug('after request: %s (%d) => %s', url, result.response.status, err);
|
|
99
|
+
if (err) {
|
|
100
|
+
return;
|
|
158
101
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
102
|
+
const span = trace.getSpan(context.active());
|
|
103
|
+
switch (options.telemetry?.name) {
|
|
104
|
+
case 'agentuity.keyvalue.get': {
|
|
105
|
+
if (result.response.status === 404) {
|
|
106
|
+
span?.addEvent('miss');
|
|
107
|
+
} else if (result.response.ok) {
|
|
108
|
+
span?.addEvent('hit');
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
case 'agentuity.stream.create': {
|
|
113
|
+
if (result.response.ok) {
|
|
114
|
+
const res = result.data as { id: string };
|
|
115
|
+
span?.setAttributes({
|
|
116
|
+
'stream.id': res.id,
|
|
117
|
+
'stream.url': `${streamBaseUrl}/${res.id}`,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
case 'agentuity.stream.list': {
|
|
123
|
+
const response = result.data as ListStreamsResponse;
|
|
124
|
+
if (response && span) {
|
|
125
|
+
span.setAttributes({
|
|
126
|
+
'stream.count': response.streams.length,
|
|
127
|
+
'stream.total': response.total,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
case 'agentuity.vector.upsert': {
|
|
133
|
+
if (result.response.ok) {
|
|
134
|
+
const data = result.data as VectorUpsertResult[];
|
|
135
|
+
span?.setAttributes({
|
|
136
|
+
'vector.count': data.length,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
case 'agentuity.vector.search': {
|
|
142
|
+
if (result.response.ok) {
|
|
143
|
+
const data = result.data as VectorSearchResult[];
|
|
144
|
+
span?.setAttributes({
|
|
145
|
+
'vector.results': data.length,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
case 'agentuity.vector.get': {
|
|
151
|
+
if (result.response.status === 404) {
|
|
152
|
+
span?.addEvent('miss');
|
|
153
|
+
} else if (result.response.ok) {
|
|
154
|
+
span?.addEvent('hit');
|
|
155
|
+
}
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
case 'agentuity.objectstore.get': {
|
|
159
|
+
if (result.response.status === 404) {
|
|
160
|
+
span?.addEvent('miss');
|
|
161
|
+
} else if (result.response.ok) {
|
|
162
|
+
span?.addEvent('hit');
|
|
163
|
+
}
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
case 'agentuity.objectstore.delete': {
|
|
167
|
+
if (result.response.status === 404) {
|
|
168
|
+
span?.addEvent('not_found', { deleted: false });
|
|
169
|
+
} else if (result.response.ok) {
|
|
170
|
+
span?.addEvent('deleted', { deleted: true });
|
|
171
|
+
}
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
166
174
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
});
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
logger
|
|
178
|
+
);
|
|
172
179
|
|
|
173
180
|
let kv: KeyValueStorage;
|
|
174
181
|
let objectStore: ObjectStorage;
|
|
@@ -185,6 +192,7 @@ let localRouter: any | null = null;
|
|
|
185
192
|
export function createServices(logger: Logger, config?: AppConfig, serverUrl?: string) {
|
|
186
193
|
const authenticated = isAuthenticated();
|
|
187
194
|
const useLocal = config?.services?.useLocal ?? false;
|
|
195
|
+
adapter = createFetchAdapter(logger);
|
|
188
196
|
|
|
189
197
|
// Use local services if explicitly requested OR if not authenticated
|
|
190
198
|
const shouldUseLocal =
|
|
@@ -234,23 +242,25 @@ export function createServices(logger: Logger, config?: AppConfig, serverUrl?: s
|
|
|
234
242
|
vector = config?.services?.vector || new VectorStorageService(vectorBaseUrl, adapter);
|
|
235
243
|
session = config?.services?.session || new DefaultSessionProvider();
|
|
236
244
|
thread = config?.services?.thread || new DefaultThreadProvider();
|
|
245
|
+
// FIXME: this is turned off for now for production until we have the new changes deployed
|
|
237
246
|
sessionEvent =
|
|
238
247
|
isProduction() && process.env.AGENTUITY_CLOUD_EXPORT_DIR
|
|
239
248
|
? new JSONSessionEventProvider(process.env.AGENTUITY_CLOUD_EXPORT_DIR)
|
|
240
|
-
:
|
|
241
|
-
|
|
242
|
-
// ? new HTTPSessionEventProvider(new APIClient(catalystBaseUrl, logger))
|
|
243
|
-
new LocalSessionEventProvider();
|
|
249
|
+
: new HTTPSessionEventProvider(new APIClient(catalystBaseUrl, logger), logger);
|
|
250
|
+
new LocalSessionEventProvider();
|
|
244
251
|
if (config?.services?.sessionEvent) {
|
|
245
252
|
sessionEvent = new CompositeSessionEventProvider(sessionEvent, config.services.sessionEvent);
|
|
246
253
|
}
|
|
254
|
+
// FIXME: this is turned off for now for production until we have the new changes deployed
|
|
247
255
|
evalRunEvent =
|
|
248
256
|
isProduction() && process.env.AGENTUITY_CLOUD_EXPORT_DIR
|
|
249
257
|
? new JSONEvalRunEventProvider(process.env.AGENTUITY_CLOUD_EXPORT_DIR)
|
|
250
|
-
:
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
258
|
+
: new HTTPEvalRunEventProvider(
|
|
259
|
+
new APIClient(catalystBaseUrl, logger),
|
|
260
|
+
logger,
|
|
261
|
+
catalystBaseUrl
|
|
262
|
+
);
|
|
263
|
+
new LocalEvalRunEventProvider();
|
|
254
264
|
if (config?.services?.evalRunEvent) {
|
|
255
265
|
evalRunEvent = new CompositeEvalRunEventProvider(evalRunEvent, config.services.evalRunEvent);
|
|
256
266
|
}
|
package/src/_tokens.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { Context, AttributeValue } from '@opentelemetry/api';
|
|
2
|
+
import type { Span } from '@opentelemetry/sdk-trace-base';
|
|
3
|
+
import type { SpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
4
|
+
import { inAgentContext, inHTTPContext, getHTTPContext } from './_context';
|
|
5
|
+
import { SpanAttributes } from '@traceloop/ai-semantic-conventions';
|
|
6
|
+
import { addSpanProcessor } from './_server';
|
|
7
|
+
|
|
8
|
+
export const TOKENS_HEADER = 'x-agentuity-tokens';
|
|
9
|
+
|
|
10
|
+
const AI_SDK_SPAN_NAME = 'ai.generateText';
|
|
11
|
+
const AI_SDK_MODEL_NAME = 'ai.model.id';
|
|
12
|
+
const AI_SDK_USAGE_PROMPT_TOKENS = 'ai.usage.promptTokens';
|
|
13
|
+
const AI_SDK_USAGE_COMPLETION_TOKENS = 'ai.usage.completionTokens';
|
|
14
|
+
|
|
15
|
+
const parseTokenHeader = (val: string | undefined): Map<string, number> => {
|
|
16
|
+
const kv = new Map<string, number>();
|
|
17
|
+
if (val) {
|
|
18
|
+
// format is: [model]:[count] [model:count]
|
|
19
|
+
const tok = val.split(' ');
|
|
20
|
+
for (const entry of tok) {
|
|
21
|
+
const [name, count] = entry.split(':');
|
|
22
|
+
if (name) {
|
|
23
|
+
kv.set(name, parseInt(count ?? '0') ?? 0);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return kv;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const serializeTokenHeader = (kv: Map<string, number>): string => {
|
|
31
|
+
const lines: string[] = [];
|
|
32
|
+
for (const [k, v] of kv) {
|
|
33
|
+
lines.push(`${k}:${v}`);
|
|
34
|
+
}
|
|
35
|
+
return lines.join(' ');
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const getTokenValue = (val: AttributeValue | undefined): number => {
|
|
39
|
+
if (val) {
|
|
40
|
+
const v = val.valueOf();
|
|
41
|
+
switch (typeof v) {
|
|
42
|
+
case 'number':
|
|
43
|
+
return v;
|
|
44
|
+
case 'string':
|
|
45
|
+
return parseInt(v, 10);
|
|
46
|
+
default:
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return 0;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
class TokenSpanProcessor implements SpanProcessor {
|
|
53
|
+
onStart(_span: Span, _context: Context) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
onEnd(span: Span) {
|
|
58
|
+
if (inAgentContext() && inHTTPContext()) {
|
|
59
|
+
const ctx = getHTTPContext();
|
|
60
|
+
const tokenLine = ctx.res.headers.get(TOKENS_HEADER) ?? undefined;
|
|
61
|
+
const tokens = parseTokenHeader(tokenLine);
|
|
62
|
+
let mutated = false;
|
|
63
|
+
// this is AI SDK which doesn't seem to use the semantic attribute names
|
|
64
|
+
if (span.name === AI_SDK_SPAN_NAME && AI_SDK_MODEL_NAME in span.attributes) {
|
|
65
|
+
const model = span.attributes[AI_SDK_MODEL_NAME]!.toString();
|
|
66
|
+
let totalTokens = tokens.get(model) ?? 0;
|
|
67
|
+
if (AI_SDK_USAGE_PROMPT_TOKENS in span.attributes) {
|
|
68
|
+
totalTokens += getTokenValue(span.attributes[AI_SDK_USAGE_PROMPT_TOKENS]);
|
|
69
|
+
}
|
|
70
|
+
if (AI_SDK_USAGE_COMPLETION_TOKENS in span.attributes) {
|
|
71
|
+
totalTokens += getTokenValue(span.attributes[AI_SDK_USAGE_COMPLETION_TOKENS]);
|
|
72
|
+
}
|
|
73
|
+
if (totalTokens > 0) {
|
|
74
|
+
tokens.set(model, totalTokens);
|
|
75
|
+
mutated = true;
|
|
76
|
+
}
|
|
77
|
+
} else if (
|
|
78
|
+
SpanAttributes.LLM_SYSTEM in span.attributes &&
|
|
79
|
+
SpanAttributes.LLM_RESPONSE_MODEL in span.attributes
|
|
80
|
+
) {
|
|
81
|
+
const model = span.attributes[SpanAttributes.LLM_RESPONSE_MODEL]!.toString();
|
|
82
|
+
let totalTokens = tokens.get(model) ?? 0;
|
|
83
|
+
if (SpanAttributes.LLM_USAGE_PROMPT_TOKENS in span.attributes) {
|
|
84
|
+
totalTokens += getTokenValue(
|
|
85
|
+
span.attributes[SpanAttributes.LLM_USAGE_PROMPT_TOKENS]
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
if (SpanAttributes.LLM_USAGE_COMPLETION_TOKENS in span.attributes) {
|
|
89
|
+
totalTokens += getTokenValue(
|
|
90
|
+
span.attributes[SpanAttributes.LLM_USAGE_COMPLETION_TOKENS]
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
if (totalTokens > 0) {
|
|
94
|
+
tokens.set(model, totalTokens);
|
|
95
|
+
mutated = true;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (mutated) {
|
|
99
|
+
ctx.header(TOKENS_HEADER, serializeTokenHeader(tokens));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
forceFlush() {
|
|
105
|
+
return Promise.resolve();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
shutdown() {
|
|
109
|
+
return Promise.resolve();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export default function register() {
|
|
114
|
+
addSpanProcessor(new TokenSpanProcessor());
|
|
115
|
+
}
|
package/src/agent.ts
CHANGED
|
@@ -6,8 +6,7 @@ import type {
|
|
|
6
6
|
StreamStorage,
|
|
7
7
|
VectorStorage,
|
|
8
8
|
} from '@agentuity/core';
|
|
9
|
-
import type
|
|
10
|
-
import { SpanStatusCode, context, trace } from '@opentelemetry/api';
|
|
9
|
+
import { context, SpanStatusCode, type Tracer, trace } from '@opentelemetry/api';
|
|
11
10
|
import type { Context, MiddlewareHandler } from 'hono';
|
|
12
11
|
import { getAgentContext, runInAgentContext, type RequestAgentContextArgs } from './_context';
|
|
13
12
|
import type { Logger } from './logger';
|
|
@@ -63,15 +62,15 @@ export interface AgentContext {
|
|
|
63
62
|
|
|
64
63
|
type InternalAgentMetadata = {
|
|
65
64
|
/**
|
|
66
|
-
* the unique identifier for this agent and
|
|
65
|
+
* the unique identifier for this project, agent and deployment.
|
|
67
66
|
*/
|
|
68
67
|
id: string;
|
|
69
68
|
/**
|
|
70
|
-
* the
|
|
69
|
+
* the unique identifier for this project and agent across multiple deployments.
|
|
71
70
|
*/
|
|
72
71
|
identifier: string;
|
|
73
72
|
/**
|
|
74
|
-
* the relative path to the agent from the root project directory
|
|
73
|
+
* the relative path to the agent from the root project directory.
|
|
75
74
|
*/
|
|
76
75
|
filename: string;
|
|
77
76
|
/**
|
|
@@ -82,13 +81,13 @@ type InternalAgentMetadata = {
|
|
|
82
81
|
|
|
83
82
|
type ExternalAgentMetadata = {
|
|
84
83
|
/**
|
|
85
|
-
* the human readable name for the agent
|
|
84
|
+
* the human readable name for the agent.
|
|
86
85
|
*/
|
|
87
86
|
name: string;
|
|
88
87
|
/**
|
|
89
|
-
* the human readable description for the agent
|
|
88
|
+
* the human readable description for the agent
|
|
90
89
|
*/
|
|
91
|
-
description
|
|
90
|
+
description?: string;
|
|
92
91
|
};
|
|
93
92
|
|
|
94
93
|
type AgentMetadata = InternalAgentMetadata & ExternalAgentMetadata;
|
|
@@ -271,7 +270,7 @@ export function createAgent<
|
|
|
271
270
|
output?: TOutput;
|
|
272
271
|
stream?: TStream;
|
|
273
272
|
};
|
|
274
|
-
metadata
|
|
273
|
+
metadata: ExternalAgentMetadata;
|
|
275
274
|
handler: TInput extends StandardSchemaV1
|
|
276
275
|
? TStream extends true
|
|
277
276
|
? TOutput extends StandardSchemaV1
|
|
@@ -386,7 +385,7 @@ export function createAgent<
|
|
|
386
385
|
|
|
387
386
|
// Create createEval method that infers types from agent and automatically adds to agent
|
|
388
387
|
const createEval = (evalConfig: {
|
|
389
|
-
metadata?: Partial<
|
|
388
|
+
metadata?: Partial<EvalMetadata>;
|
|
390
389
|
handler: EvalFunction<AgentInput, AgentOutput>;
|
|
391
390
|
}): Eval<TInput, TOutput> => {
|
|
392
391
|
const evalName = evalConfig.metadata?.name || 'unnamed';
|
|
@@ -398,42 +397,52 @@ export function createAgent<
|
|
|
398
397
|
// Get filename (can be provided via __filename or set by bundler)
|
|
399
398
|
const filename = evalConfig.metadata?.filename || '';
|
|
400
399
|
|
|
401
|
-
//
|
|
402
|
-
|
|
403
|
-
if (!identifier && filename) {
|
|
404
|
-
const pathParts = filename.split(/[/\\]/);
|
|
405
|
-
const basename = pathParts[pathParts.length - 1] || '';
|
|
406
|
-
identifier = basename.replace(/\.(ts|tsx|js|jsx)$/, '') || '';
|
|
407
|
-
}
|
|
400
|
+
// Use name as identifier for consistency (same as agents)
|
|
401
|
+
const identifier = evalName;
|
|
408
402
|
|
|
409
|
-
// Use
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
403
|
+
// Use build-time injected id/version if available, otherwise generate at runtime
|
|
404
|
+
// Build-time injection happens via bundler AST transformation
|
|
405
|
+
let evalId = evalConfig.metadata?.id;
|
|
406
|
+
let stableEvalId = evalConfig.metadata?.evalId;
|
|
407
|
+
let version = evalConfig.metadata?.version;
|
|
413
408
|
|
|
414
|
-
// Generate
|
|
415
|
-
const projectId = runtimeConfig.getProjectId() || '';
|
|
416
|
-
const deploymentId = runtimeConfig.getDeploymentId() || '';
|
|
417
|
-
// Generate version from available metadata (deterministic hash)
|
|
409
|
+
// Generate version from available metadata if not provided (deterministic hash)
|
|
418
410
|
// At build-time, version is hash of file contents; at runtime we use metadata
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
411
|
+
if (!version) {
|
|
412
|
+
const versionHasher = new Bun.CryptoHasher('sha1');
|
|
413
|
+
versionHasher.update(identifier);
|
|
414
|
+
versionHasher.update(evalName);
|
|
415
|
+
versionHasher.update(filename);
|
|
416
|
+
version = versionHasher.digest('hex');
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// Generate eval ID using same logic as build-time (getEvalId) if not provided
|
|
425
420
|
// Format: eval_${hashSHA1(projectId, deploymentId, filename, name, version)}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
421
|
+
if (!evalId) {
|
|
422
|
+
const projectId = runtimeConfig.getProjectId() || '';
|
|
423
|
+
const deploymentId = runtimeConfig.getDeploymentId() || '';
|
|
424
|
+
const idHasher = new Bun.CryptoHasher('sha1');
|
|
425
|
+
idHasher.update(projectId);
|
|
426
|
+
idHasher.update(deploymentId);
|
|
427
|
+
idHasher.update(filename);
|
|
428
|
+
idHasher.update(evalName);
|
|
429
|
+
idHasher.update(version);
|
|
430
|
+
evalId = `eval_${idHasher.digest('hex')}`;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// Generate stable evalId if not provided (for project-wide identification)
|
|
434
|
+
if (!stableEvalId) {
|
|
435
|
+
const projectId = runtimeConfig.getProjectId() || '';
|
|
436
|
+
const stableHasher = new Bun.CryptoHasher('sha1');
|
|
437
|
+
stableHasher.update(projectId);
|
|
438
|
+
stableHasher.update(evalName);
|
|
439
|
+
stableEvalId = `evalid_${stableHasher.digest('hex')}`.substring(0, 64);
|
|
440
|
+
}
|
|
433
441
|
|
|
434
442
|
const evalType: any = {
|
|
435
443
|
metadata: {
|
|
436
444
|
id: evalId,
|
|
445
|
+
evalId: stableEvalId,
|
|
437
446
|
version,
|
|
438
447
|
identifier,
|
|
439
448
|
name: evalConfig.metadata?.name || '',
|
|
@@ -548,6 +557,7 @@ export function createAgent<
|
|
|
548
557
|
`[EVALRUN] Sending start event for eval '${evalName}' (id: ${evalRunId}, evalId: ${evalId})`
|
|
549
558
|
);
|
|
550
559
|
try {
|
|
560
|
+
const deploymentId = runtimeConfig.getDeploymentId();
|
|
551
561
|
const startEvent: EvalRunStartEvent = {
|
|
552
562
|
id: evalRunId,
|
|
553
563
|
sessionId: ctx.sessionId,
|
|
@@ -555,6 +565,7 @@ export function createAgent<
|
|
|
555
565
|
orgId: orgId!,
|
|
556
566
|
projectId: projectId!,
|
|
557
567
|
devmode: Boolean(devMode),
|
|
568
|
+
deploymentId: deploymentId || undefined,
|
|
558
569
|
};
|
|
559
570
|
internal.debug(
|
|
560
571
|
'[EVALRUN] Start event payload: %s',
|
|
@@ -891,3 +902,5 @@ export const createAgentMiddleware = (agentName: AgentName): MiddlewareHandler =
|
|
|
891
902
|
);
|
|
892
903
|
};
|
|
893
904
|
};
|
|
905
|
+
|
|
906
|
+
export const getAgents = () => agents;
|
package/src/eval.ts
CHANGED
|
@@ -33,10 +33,10 @@ export type EvalRunResult = EvalRunResultBinary | EvalRunResultScore | EvalRunRe
|
|
|
33
33
|
export type CreateEvalRunRequest = {
|
|
34
34
|
projectId: string;
|
|
35
35
|
sessionId: string;
|
|
36
|
-
spanId: string;
|
|
37
36
|
result: EvalRunResult;
|
|
38
37
|
evalId: string;
|
|
39
38
|
promptHash?: string;
|
|
39
|
+
deploymentId?: string;
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
type InternalEvalMetadata = {
|
|
@@ -44,6 +44,10 @@ type InternalEvalMetadata = {
|
|
|
44
44
|
* the unique identifier for this eval and project
|
|
45
45
|
*/
|
|
46
46
|
id: string;
|
|
47
|
+
/**
|
|
48
|
+
* the unique identifier for this project and eval across multiple deployments.
|
|
49
|
+
*/
|
|
50
|
+
evalId: string;
|
|
47
51
|
/**
|
|
48
52
|
* the folder name for the eval
|
|
49
53
|
*/
|
package/src/index.ts
CHANGED
package/src/router.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { stream as honoStream, streamSSE as honoStreamSSE } from 'hono/streaming
|
|
|
5
5
|
import { upgradeWebSocket as honoUpgradeWebSocket } from 'hono/bun';
|
|
6
6
|
import { hash, returnResponse } from './_util';
|
|
7
7
|
import type { Env } from './app';
|
|
8
|
-
import {
|
|
8
|
+
import { getAgentAsyncLocalStorage } from './_context';
|
|
9
9
|
import { parseEmail, type Email } from './io/email';
|
|
10
10
|
|
|
11
11
|
type AgentHandler<E extends Env = Env, P extends string = string, I extends Input = {}> = (
|
|
@@ -208,7 +208,7 @@ export const createRouter = <E extends Env = Env, S extends Schema = Schema>():
|
|
|
208
208
|
|
|
209
209
|
const wrapper = (c: Context) => {
|
|
210
210
|
// Capture the AgentContext from the request
|
|
211
|
-
const asyncLocalStorage =
|
|
211
|
+
const asyncLocalStorage = getAgentAsyncLocalStorage();
|
|
212
212
|
const capturedContext = asyncLocalStorage.getStore();
|
|
213
213
|
|
|
214
214
|
return honoStream(c, async (s: any) => {
|
|
@@ -256,7 +256,7 @@ export const createRouter = <E extends Env = Env, S extends Schema = Schema>():
|
|
|
256
256
|
let initialized = false;
|
|
257
257
|
|
|
258
258
|
// Capture the AgentContext from the upgrade request
|
|
259
|
-
const asyncLocalStorage =
|
|
259
|
+
const asyncLocalStorage = getAgentAsyncLocalStorage();
|
|
260
260
|
const capturedContext = asyncLocalStorage.getStore();
|
|
261
261
|
|
|
262
262
|
const wsConnection: WebSocketConnection = {
|
|
@@ -388,7 +388,7 @@ export const createRouter = <E extends Env = Env, S extends Schema = Schema>():
|
|
|
388
388
|
|
|
389
389
|
const wrapper = (c: Context) => {
|
|
390
390
|
// Capture the AgentContext from the request
|
|
391
|
-
const asyncLocalStorage =
|
|
391
|
+
const asyncLocalStorage = getAgentAsyncLocalStorage();
|
|
392
392
|
const capturedContext = asyncLocalStorage.getStore();
|
|
393
393
|
|
|
394
394
|
return honoStreamSSE(c, async (stream: any) => {
|
|
@@ -4,6 +4,8 @@ import type {
|
|
|
4
4
|
DataResult,
|
|
5
5
|
DataResultNotFound,
|
|
6
6
|
KeyValueStorageSetParams,
|
|
7
|
+
KeyValueStats,
|
|
8
|
+
KeyValueItemWithMetadata,
|
|
7
9
|
} from '@agentuity/core';
|
|
8
10
|
import { now } from './_util';
|
|
9
11
|
|
|
@@ -115,4 +117,35 @@ export class LocalKeyValueStorage implements KeyValueStorage {
|
|
|
115
117
|
|
|
116
118
|
stmt.run(this.#projectPath, name, key);
|
|
117
119
|
}
|
|
120
|
+
|
|
121
|
+
async getStats(_name: string): Promise<KeyValueStats> {
|
|
122
|
+
throw new Error('getStats not implemented for local storage');
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async getAllStats(): Promise<Record<string, KeyValueStats>> {
|
|
126
|
+
throw new Error('getAllStats not implemented for local storage');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async getNamespaces(): Promise<string[]> {
|
|
130
|
+
throw new Error('getNamespaces not implemented for local storage');
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async search<T = unknown>(
|
|
134
|
+
_name: string,
|
|
135
|
+
_keyword: string
|
|
136
|
+
): Promise<Record<string, KeyValueItemWithMetadata<T>>> {
|
|
137
|
+
throw new Error('search not implemented for local storage');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async getKeys(_name: string): Promise<string[]> {
|
|
141
|
+
throw new Error('getKeys not implemented for local storage');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async deleteNamespace(_name: string): Promise<void> {
|
|
145
|
+
throw new Error('deleteNamespace not implemented for local storage');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async createNamespace(_name: string): Promise<void> {
|
|
149
|
+
throw new Error('createNamespace not implemented for local storage');
|
|
150
|
+
}
|
|
118
151
|
}
|
|
@@ -5,6 +5,8 @@ import type {
|
|
|
5
5
|
ObjectResultNotFound,
|
|
6
6
|
ObjectStorePutParams,
|
|
7
7
|
CreatePublicURLParams,
|
|
8
|
+
BucketInfo,
|
|
9
|
+
ObjectInfo,
|
|
8
10
|
} from '@agentuity/core';
|
|
9
11
|
import { now } from './_util';
|
|
10
12
|
|
|
@@ -149,4 +151,27 @@ export class LocalObjectStorage implements ObjectStorage {
|
|
|
149
151
|
// Note: params.expiresDuration is ignored for local implementation
|
|
150
152
|
return `${this.#serverUrl}/_agentuity/local/object/${encodeURIComponent(bucket)}/${encodeURIComponent(key)}`;
|
|
151
153
|
}
|
|
154
|
+
|
|
155
|
+
async listBuckets(): Promise<BucketInfo[]> {
|
|
156
|
+
throw new Error('listBuckets not implemented for local storage');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async listKeys(_bucket: string): Promise<ObjectInfo[]> {
|
|
160
|
+
throw new Error('listKeys not implemented for local storage');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async listObjects(
|
|
164
|
+
_bucket: string,
|
|
165
|
+
_options?: { prefix?: string; limit?: number }
|
|
166
|
+
): Promise<ObjectInfo[]> {
|
|
167
|
+
throw new Error('listObjects not implemented for local storage');
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async headObject(_bucket: string, _key: string): Promise<ObjectInfo> {
|
|
171
|
+
throw new Error('headObject not implemented for local storage');
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async deleteBucket(_bucket: string): Promise<boolean> {
|
|
175
|
+
throw new Error('deleteBucket not implemented for local storage');
|
|
176
|
+
}
|
|
152
177
|
}
|
package/src/workbench.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Handler } from 'hono';
|
|
3
|
+
import { timingSafeEqual } from 'node:crypto';
|
|
4
|
+
import { getAgents } from './agent';
|
|
5
|
+
|
|
6
|
+
export const createWorkbenchMetadataRoute = (): Handler => {
|
|
7
|
+
const authHeader = process.env.AGENTUITY_WORKBENCH_APIKEY
|
|
8
|
+
? `Bearer ${process.env.AGENTUITY_WORKBENCH_APIKEY}`
|
|
9
|
+
: undefined;
|
|
10
|
+
const agents = getAgents();
|
|
11
|
+
return async (ctx) => {
|
|
12
|
+
if (authHeader) {
|
|
13
|
+
try {
|
|
14
|
+
const authValue = ctx.req.header('Authorization');
|
|
15
|
+
if (
|
|
16
|
+
!authValue ||
|
|
17
|
+
!timingSafeEqual(Buffer.from(authValue, 'utf-8'), Buffer.from(authHeader, 'utf-8'))
|
|
18
|
+
) {
|
|
19
|
+
return ctx.text('Unauthorized', { status: 401 });
|
|
20
|
+
}
|
|
21
|
+
} catch {
|
|
22
|
+
// timing safe equals will throw if the input/output lengths are mismatched
|
|
23
|
+
// so we treat all exceptions as invalid
|
|
24
|
+
return ctx.text('Unauthorized', { status: 401 });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const schemas: { agents: Record<string, unknown> } = { agents: {} };
|
|
28
|
+
// TODO: this is going to only work for zod schema for now. need a way to handle others
|
|
29
|
+
for (const [, agent] of agents) {
|
|
30
|
+
schemas.agents[agent.metadata.name] = {
|
|
31
|
+
schema: {
|
|
32
|
+
input: agent.inputSchema ? z.toJSONSchema(agent.inputSchema) : undefined,
|
|
33
|
+
output: agent.outputSchema ? z.toJSONSchema(agent.outputSchema) : undefined,
|
|
34
|
+
},
|
|
35
|
+
metadata: agent.metadata,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return ctx.json(schemas);
|
|
39
|
+
};
|
|
40
|
+
};
|