@withgateway/sdk 0.1.7 → 0.1.9
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-CubrUmOe.d.mts → index-CTc8iOrx.d.mts} +13 -0
- package/dist/{index-CubrUmOe.d.ts → index-CTc8iOrx.d.ts} +13 -0
- package/dist/index.d.mts +60 -4
- package/dist/index.d.ts +60 -4
- package/dist/index.js +414 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +407 -3
- package/dist/index.mjs.map +1 -1
- package/dist/tracing/index.d.mts +1 -1
- package/dist/tracing/index.d.ts +1 -1
- package/dist/tracing/index.js +358 -3
- package/dist/tracing/index.js.map +1 -1
- package/dist/tracing/index.mjs +359 -3
- package/dist/tracing/index.mjs.map +1 -1
- package/dist/users/index.d.mts +50 -1
- package/dist/users/index.d.ts +50 -1
- package/dist/users/index.js +64 -0
- package/dist/users/index.js.map +1 -1
- package/dist/users/index.mjs +64 -0
- package/dist/users/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -99,6 +99,19 @@ interface TracingConfig {
|
|
|
99
99
|
* Sets resource attribute for filtering traces in Gateway.
|
|
100
100
|
*/
|
|
101
101
|
environment?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Agent identity (gateway.agent.id). When set, the SDK assembles the
|
|
104
|
+
* build manifest from everything registered so far (defineTool /
|
|
105
|
+
* registerPrompt), stamps gateway.build.hash on every span, and
|
|
106
|
+
* auto-registers the build with Gateway (idempotent on hash). Define
|
|
107
|
+
* tools BEFORE init so they join the build identity.
|
|
108
|
+
*/
|
|
109
|
+
agent?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Set false to stamp build identity without registering it with Gateway.
|
|
112
|
+
* Defaults to true when `agent` is set.
|
|
113
|
+
*/
|
|
114
|
+
registerBuild?: boolean;
|
|
102
115
|
/**
|
|
103
116
|
* Application version (e.g., "1.2.3", git SHA).
|
|
104
117
|
* Sets resource attribute for tracking regressions.
|
|
@@ -99,6 +99,19 @@ interface TracingConfig {
|
|
|
99
99
|
* Sets resource attribute for filtering traces in Gateway.
|
|
100
100
|
*/
|
|
101
101
|
environment?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Agent identity (gateway.agent.id). When set, the SDK assembles the
|
|
104
|
+
* build manifest from everything registered so far (defineTool /
|
|
105
|
+
* registerPrompt), stamps gateway.build.hash on every span, and
|
|
106
|
+
* auto-registers the build with Gateway (idempotent on hash). Define
|
|
107
|
+
* tools BEFORE init so they join the build identity.
|
|
108
|
+
*/
|
|
109
|
+
agent?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Set false to stamp build identity without registering it with Gateway.
|
|
112
|
+
* Defaults to true when `agent` is set.
|
|
113
|
+
*/
|
|
114
|
+
registerBuild?: boolean;
|
|
102
115
|
/**
|
|
103
116
|
* Application version (e.g., "1.2.3", git SHA).
|
|
104
117
|
* Sets resource attribute for tracking regressions.
|
package/dist/index.d.mts
CHANGED
|
@@ -5,13 +5,69 @@ export { Persona, PersonaError, PersonaMessage, PersonaReply, PersonasClient, Pe
|
|
|
5
5
|
export { DriftError, LocalTool, MissPolicy, REPLAY_ENVIRONMENT, RecordedToolCall, ReplayAgent, ReplayCase, ReplayCheck, ReplayCredentials, ReplayError, ReplayMode, ReplayReport, ReplayStatus, ReplaySuite, ReplaySuiteLoadOptions, ReplayTask, RunSuiteOptions, SessionLoader, StubCallLogEntry, StubFallback, StubMatch, StubMissError, StubRegistryMapping, ToolStub, ToolStubRegistry, TraceDiff, replay, runSuite, suite } from './replay/index.mjs';
|
|
6
6
|
export { GatewayAgentDescriptor, GatewaySecurity, GatewaySecurityConfig, GatewaySecurityContext, GatewaySecurityError, GatewayToolApprovalRequiredError, GatewayToolBlockedError, GatewayToolCallAuthorizeResponse, GatewayToolDescriptor, GatewayToolsetResolveResponse, SecureToolsOptions, gateway } from './security/index.mjs';
|
|
7
7
|
export { DEFAULT_TIMEOUT_SECONDS, ENV_GATEWAY_HOST, ENV_GATEWAY_PUBLIC_KEY, ENV_GATEWAY_SECRET_KEY, LoadSessionOptions, SessionLoadError, SessionObservation, SessionRecording, SessionTrace, basicAuthHeader, loadSession, sessionObservationFromApi, sessions } from './sessions/index.mjs';
|
|
8
|
-
export { UserProfile, UserProfileError, UserProfileUpdate, UsersClient, UsersClientConfig, UsersClientFromEnvConfig, users } from './users/index.mjs';
|
|
9
|
-
import { _ as _tracingModule } from './index-
|
|
10
|
-
export { I as IdentifyOptions, i as identify, r as resolveUserId } from './index-
|
|
8
|
+
export { UserEvent, UserEventOptions, UserProfile, UserProfileError, UserProfileUpdate, UsersClient, UsersClientConfig, UsersClientFromEnvConfig, users } from './users/index.mjs';
|
|
9
|
+
import { _ as _tracingModule } from './index-CTc8iOrx.mjs';
|
|
10
|
+
export { I as IdentifyOptions, i as identify, r as resolveUserId } from './index-CTc8iOrx.mjs';
|
|
11
11
|
import 'async_hooks';
|
|
12
12
|
import '@opentelemetry/api';
|
|
13
13
|
import '@opentelemetry/sdk-trace-base';
|
|
14
14
|
|
|
15
|
+
type ToolEffects = "read" | "write" | "irreversible";
|
|
16
|
+
interface ToolIdentity {
|
|
17
|
+
name: string;
|
|
18
|
+
version?: string;
|
|
19
|
+
effects?: ToolEffects;
|
|
20
|
+
schemaHash: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
/** Source location of the defineTool call ("src/tools/checkout.ts:42"). */
|
|
23
|
+
source?: string;
|
|
24
|
+
}
|
|
25
|
+
interface AgentBuildManifest {
|
|
26
|
+
agentId: string;
|
|
27
|
+
codeRef?: string;
|
|
28
|
+
sdk: string;
|
|
29
|
+
tools: ToolIdentity[];
|
|
30
|
+
prompts: Record<string, string>;
|
|
31
|
+
}
|
|
32
|
+
/** Deterministic JSON: object keys sorted recursively, arrays kept in order. */
|
|
33
|
+
declare function canonicalJson(value: unknown): string;
|
|
34
|
+
interface DefineToolInput {
|
|
35
|
+
name: string;
|
|
36
|
+
/** Developer-declared tool version, e.g. "2.1" (v1: bumped manually). */
|
|
37
|
+
version?: string;
|
|
38
|
+
/** Side-effect class — feeds approval policies and gate severity. */
|
|
39
|
+
effects?: ToolEffects;
|
|
40
|
+
description?: string;
|
|
41
|
+
/** JSON schema (or zod-serializable shape) of the tool's parameters. */
|
|
42
|
+
schema?: unknown;
|
|
43
|
+
/** Alias accepted for frameworks that call it inputSchema. */
|
|
44
|
+
inputSchema?: unknown;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Register a tool's identity and pass the definition through unchanged, so
|
|
48
|
+
* it wraps ANY framework's tool shape:
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* const checkout = defineTool({
|
|
52
|
+
* name: "checkout", version: "2.1", effects: "write",
|
|
53
|
+
* schema, description, execute,
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
declare function defineTool<T extends DefineToolInput>(tool: T): T;
|
|
58
|
+
/**
|
|
59
|
+
* Register a code-shipped prompt so it joins the build identity:
|
|
60
|
+
* `const SYSTEM = registerPrompt("system", "You are…")`. Returns the content
|
|
61
|
+
* unchanged. Platform-served prompts don't need this — pin them by label.
|
|
62
|
+
*/
|
|
63
|
+
declare function registerPrompt(name: string, content: string): string;
|
|
64
|
+
declare function getRegisteredTools(): ToolIdentity[];
|
|
65
|
+
declare function getRegisteredPrompts(): Record<string, string>;
|
|
66
|
+
/** Test hook. */
|
|
67
|
+
declare function resetBuildRegistry(): void;
|
|
68
|
+
declare function assembleManifest(agentId: string): AgentBuildManifest;
|
|
69
|
+
declare function computeBuildHash(manifest: AgentBuildManifest): string;
|
|
70
|
+
|
|
15
71
|
/**
|
|
16
72
|
* Tracing module with automatic ExperimentSpanProcessor wiring.
|
|
17
73
|
*
|
|
@@ -22,4 +78,4 @@ import '@opentelemetry/sdk-trace-base';
|
|
|
22
78
|
*/
|
|
23
79
|
declare const tracing: typeof _tracingModule;
|
|
24
80
|
|
|
25
|
-
export { tracing };
|
|
81
|
+
export { type AgentBuildManifest, type DefineToolInput, type ToolEffects, type ToolIdentity, assembleManifest, canonicalJson, computeBuildHash, defineTool, getRegisteredPrompts, getRegisteredTools, registerPrompt, resetBuildRegistry, tracing };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,13 +5,69 @@ export { Persona, PersonaError, PersonaMessage, PersonaReply, PersonasClient, Pe
|
|
|
5
5
|
export { DriftError, LocalTool, MissPolicy, REPLAY_ENVIRONMENT, RecordedToolCall, ReplayAgent, ReplayCase, ReplayCheck, ReplayCredentials, ReplayError, ReplayMode, ReplayReport, ReplayStatus, ReplaySuite, ReplaySuiteLoadOptions, ReplayTask, RunSuiteOptions, SessionLoader, StubCallLogEntry, StubFallback, StubMatch, StubMissError, StubRegistryMapping, ToolStub, ToolStubRegistry, TraceDiff, replay, runSuite, suite } from './replay/index.js';
|
|
6
6
|
export { GatewayAgentDescriptor, GatewaySecurity, GatewaySecurityConfig, GatewaySecurityContext, GatewaySecurityError, GatewayToolApprovalRequiredError, GatewayToolBlockedError, GatewayToolCallAuthorizeResponse, GatewayToolDescriptor, GatewayToolsetResolveResponse, SecureToolsOptions, gateway } from './security/index.js';
|
|
7
7
|
export { DEFAULT_TIMEOUT_SECONDS, ENV_GATEWAY_HOST, ENV_GATEWAY_PUBLIC_KEY, ENV_GATEWAY_SECRET_KEY, LoadSessionOptions, SessionLoadError, SessionObservation, SessionRecording, SessionTrace, basicAuthHeader, loadSession, sessionObservationFromApi, sessions } from './sessions/index.js';
|
|
8
|
-
export { UserProfile, UserProfileError, UserProfileUpdate, UsersClient, UsersClientConfig, UsersClientFromEnvConfig, users } from './users/index.js';
|
|
9
|
-
import { _ as _tracingModule } from './index-
|
|
10
|
-
export { I as IdentifyOptions, i as identify, r as resolveUserId } from './index-
|
|
8
|
+
export { UserEvent, UserEventOptions, UserProfile, UserProfileError, UserProfileUpdate, UsersClient, UsersClientConfig, UsersClientFromEnvConfig, users } from './users/index.js';
|
|
9
|
+
import { _ as _tracingModule } from './index-CTc8iOrx.js';
|
|
10
|
+
export { I as IdentifyOptions, i as identify, r as resolveUserId } from './index-CTc8iOrx.js';
|
|
11
11
|
import 'async_hooks';
|
|
12
12
|
import '@opentelemetry/api';
|
|
13
13
|
import '@opentelemetry/sdk-trace-base';
|
|
14
14
|
|
|
15
|
+
type ToolEffects = "read" | "write" | "irreversible";
|
|
16
|
+
interface ToolIdentity {
|
|
17
|
+
name: string;
|
|
18
|
+
version?: string;
|
|
19
|
+
effects?: ToolEffects;
|
|
20
|
+
schemaHash: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
/** Source location of the defineTool call ("src/tools/checkout.ts:42"). */
|
|
23
|
+
source?: string;
|
|
24
|
+
}
|
|
25
|
+
interface AgentBuildManifest {
|
|
26
|
+
agentId: string;
|
|
27
|
+
codeRef?: string;
|
|
28
|
+
sdk: string;
|
|
29
|
+
tools: ToolIdentity[];
|
|
30
|
+
prompts: Record<string, string>;
|
|
31
|
+
}
|
|
32
|
+
/** Deterministic JSON: object keys sorted recursively, arrays kept in order. */
|
|
33
|
+
declare function canonicalJson(value: unknown): string;
|
|
34
|
+
interface DefineToolInput {
|
|
35
|
+
name: string;
|
|
36
|
+
/** Developer-declared tool version, e.g. "2.1" (v1: bumped manually). */
|
|
37
|
+
version?: string;
|
|
38
|
+
/** Side-effect class — feeds approval policies and gate severity. */
|
|
39
|
+
effects?: ToolEffects;
|
|
40
|
+
description?: string;
|
|
41
|
+
/** JSON schema (or zod-serializable shape) of the tool's parameters. */
|
|
42
|
+
schema?: unknown;
|
|
43
|
+
/** Alias accepted for frameworks that call it inputSchema. */
|
|
44
|
+
inputSchema?: unknown;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Register a tool's identity and pass the definition through unchanged, so
|
|
48
|
+
* it wraps ANY framework's tool shape:
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* const checkout = defineTool({
|
|
52
|
+
* name: "checkout", version: "2.1", effects: "write",
|
|
53
|
+
* schema, description, execute,
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
declare function defineTool<T extends DefineToolInput>(tool: T): T;
|
|
58
|
+
/**
|
|
59
|
+
* Register a code-shipped prompt so it joins the build identity:
|
|
60
|
+
* `const SYSTEM = registerPrompt("system", "You are…")`. Returns the content
|
|
61
|
+
* unchanged. Platform-served prompts don't need this — pin them by label.
|
|
62
|
+
*/
|
|
63
|
+
declare function registerPrompt(name: string, content: string): string;
|
|
64
|
+
declare function getRegisteredTools(): ToolIdentity[];
|
|
65
|
+
declare function getRegisteredPrompts(): Record<string, string>;
|
|
66
|
+
/** Test hook. */
|
|
67
|
+
declare function resetBuildRegistry(): void;
|
|
68
|
+
declare function assembleManifest(agentId: string): AgentBuildManifest;
|
|
69
|
+
declare function computeBuildHash(manifest: AgentBuildManifest): string;
|
|
70
|
+
|
|
15
71
|
/**
|
|
16
72
|
* Tracing module with automatic ExperimentSpanProcessor wiring.
|
|
17
73
|
*
|
|
@@ -22,4 +78,4 @@ import '@opentelemetry/sdk-trace-base';
|
|
|
22
78
|
*/
|
|
23
79
|
declare const tracing: typeof _tracingModule;
|
|
24
80
|
|
|
25
|
-
export { tracing };
|
|
81
|
+
export { type AgentBuildManifest, type DefineToolInput, type ToolEffects, type ToolIdentity, assembleManifest, canonicalJson, computeBuildHash, defineTool, getRegisteredPrompts, getRegisteredTools, registerPrompt, resetBuildRegistry, tracing };
|