@withgateway/sdk 0.2.3 → 0.2.5
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/cli.js +13267 -5869
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +13272 -5874
- package/dist/cli.mjs.map +1 -1
- package/dist/files/index.js +83 -31
- package/dist/files/index.js.map +1 -1
- package/dist/files/index.mjs +79 -28
- package/dist/files/index.mjs.map +1 -1
- package/dist/hooks/index.d.mts +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +4355 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +4243 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/{index-Dpo-t8iO.d.ts → index-1xnxt0Cc.d.ts} +58 -2
- package/dist/index-B0R3IgsV.d.mts +1279 -0
- package/dist/index-B0R3IgsV.d.ts +1279 -0
- package/dist/{index-B5HUQQDE.d.mts → index-C1wDEwH4.d.mts} +58 -2
- package/dist/index.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +6698 -1606
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6793 -1713
- package/dist/index.mjs.map +1 -1
- package/dist/traces/index.js +72 -20
- package/dist/traces/index.js.map +1 -1
- package/dist/traces/index.mjs +68 -17
- package/dist/traces/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 +47 -3
- package/dist/tracing/index.js.map +1 -1
- package/dist/tracing/index.mjs +42 -2
- package/dist/tracing/index.mjs.map +1 -1
- package/dist/worlds/index.d.mts +390 -27
- package/dist/worlds/index.d.ts +390 -27
- package/dist/worlds/index.js +2291 -366
- package/dist/worlds/index.js.map +1 -1
- package/dist/worlds/index.mjs +2281 -356
- package/dist/worlds/index.mjs.map +1 -1
- package/package.json +7 -1
- package/runtime/gatewaysdk/environment/_bundle.py +14 -24
- package/runtime/gatewaysdk/environment/_materialize.py +3 -3
- package/runtime/gatewaysdk/environment/schema/api.py +153 -20
- package/runtime/gatewaysdk/environment/schema/compiler.py +14 -0
- package/runtime/gatewaysdk/environment/schema/data.py +21 -19
- package/runtime/gatewaysdk/environment/schema/grading.py +225 -0
- package/runtime/gatewaysdk/environment/schema/host.py +171 -535
- package/runtime/gatewaysdk/environment/schema/ingest.py +3 -11
- package/runtime/gatewaysdk/environment/schema/local.py +32 -126
- package/runtime/gatewaysdk/environment/schema/platform.py +14 -22
- package/runtime/gatewaysdk/environment/schema/proof.py +237 -0
- package/runtime/gatewaysdk/environment/schema/runtime.py +686 -0
- package/runtime/gatewaysdk/environment/schema/skill.py +1 -0
- package/runtime/gatewaysdk/environment/schema/skills/hooks-getting-started/SKILL.md +156 -0
- package/runtime/gatewaysdk/environment/schema/snapshot.py +6 -5
- package/runtime/gatewaysdk/environment/schema/tasks.py +12 -2
- package/runtime/gatewaysdk/environment/schema/tools_world.py +75 -23
- package/runtime/gatewaysdk/environment/schema/verbs.py +136 -0
- package/runtime/gatewaysdk/environment/schema/workers.py +44 -13
- package/runtime/gatewaysdk/environment/world.py +391 -0
- package/skills/hooks-getting-started/SKILL.md +156 -0
package/dist/tracing/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { I as IdentifyOptions, a as IdentitySpanProcessor, O as ObservationKind, b as ObserveClaudeOptions, c as ObserveOptions, T as TracingConfig,
|
|
1
|
+
export { I as IdentifyOptions, a as IdentitySpanProcessor, O as ObservationKind, b as ObserveClaudeOptions, c as ObserveOptions, S as SESSION_ID_ATTRIBUTE, d as SessionSpanProcessor, T as TracingConfig, e as TracingHandle, f as TracingState, U as USER_ID_ATTRIBUTE, g as flush, h as getAmbientSessionId, i as identify, j as init, k as initIsolated, l as isGatewayConfigured, m as isInitialized, o as observe, n as observeAnthropic, p as observeClaude, q as observeOpenAI, s as resetAmbientUser, r as resolveUserId, t as shutdown, w as withSession } from '../index-C1wDEwH4.mjs';
|
|
2
2
|
import '@opentelemetry/api';
|
|
3
3
|
import '../scores/index.mjs';
|
|
4
4
|
import '@opentelemetry/sdk-trace-base';
|
package/dist/tracing/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { I as IdentifyOptions, a as IdentitySpanProcessor, O as ObservationKind, b as ObserveClaudeOptions, c as ObserveOptions, T as TracingConfig,
|
|
1
|
+
export { I as IdentifyOptions, a as IdentitySpanProcessor, O as ObservationKind, b as ObserveClaudeOptions, c as ObserveOptions, S as SESSION_ID_ATTRIBUTE, d as SessionSpanProcessor, T as TracingConfig, e as TracingHandle, f as TracingState, U as USER_ID_ATTRIBUTE, g as flush, h as getAmbientSessionId, i as identify, j as init, k as initIsolated, l as isGatewayConfigured, m as isInitialized, o as observe, n as observeAnthropic, p as observeClaude, q as observeOpenAI, s as resetAmbientUser, r as resolveUserId, t as shutdown, w as withSession } from '../index-1xnxt0Cc.js';
|
|
2
2
|
import '@opentelemetry/api';
|
|
3
3
|
import '../scores/index.js';
|
|
4
4
|
import '@opentelemetry/sdk-trace-base';
|
package/dist/tracing/index.js
CHANGED
|
@@ -25,7 +25,7 @@ var require_package = __commonJS({
|
|
|
25
25
|
"package.json"(exports2, module2) {
|
|
26
26
|
module2.exports = {
|
|
27
27
|
name: "@withgateway/sdk",
|
|
28
|
-
version: "0.2.
|
|
28
|
+
version: "0.2.5",
|
|
29
29
|
description: "Gateway SDK for TypeScript - A/B experiments, tracing, and observability",
|
|
30
30
|
main: "./dist/index.js",
|
|
31
31
|
module: "./dist/index.mjs",
|
|
@@ -101,6 +101,11 @@ var require_package = __commonJS({
|
|
|
101
101
|
import: "./dist/traces/index.mjs",
|
|
102
102
|
require: "./dist/traces/index.js"
|
|
103
103
|
},
|
|
104
|
+
"./hooks": {
|
|
105
|
+
types: "./dist/hooks/index.d.ts",
|
|
106
|
+
import: "./dist/hooks/index.mjs",
|
|
107
|
+
require: "./dist/hooks/index.js"
|
|
108
|
+
},
|
|
104
109
|
"./cli": {
|
|
105
110
|
types: "./dist/cli.d.ts",
|
|
106
111
|
import: "./dist/cli.mjs",
|
|
@@ -124,6 +129,7 @@ var require_package = __commonJS({
|
|
|
124
129
|
"typecheck:examples": "tsc -p tsconfig.examples.json --noEmit",
|
|
125
130
|
test: "vitest",
|
|
126
131
|
"test:run": "vitest run",
|
|
132
|
+
"test:integration": "vitest run --config vitest.integration.config.ts",
|
|
127
133
|
lint: "eslint src --ext .ts",
|
|
128
134
|
clean: "rm -rf dist",
|
|
129
135
|
example: "tsx examples/test-ab-experiment.ts",
|
|
@@ -218,8 +224,11 @@ var require_package = __commonJS({
|
|
|
218
224
|
var tracing_exports = {};
|
|
219
225
|
__export(tracing_exports, {
|
|
220
226
|
IdentitySpanProcessor: () => IdentitySpanProcessor,
|
|
227
|
+
SESSION_ID_ATTRIBUTE: () => SESSION_ID_ATTRIBUTE,
|
|
228
|
+
SessionSpanProcessor: () => SessionSpanProcessor,
|
|
221
229
|
USER_ID_ATTRIBUTE: () => USER_ID_ATTRIBUTE,
|
|
222
230
|
flush: () => flush,
|
|
231
|
+
getAmbientSessionId: () => getAmbientSessionId,
|
|
223
232
|
identify: () => identify,
|
|
224
233
|
init: () => init,
|
|
225
234
|
initIsolated: () => initIsolated,
|
|
@@ -231,7 +240,8 @@ __export(tracing_exports, {
|
|
|
231
240
|
observeOpenAI: () => observeOpenAI,
|
|
232
241
|
resetAmbientUser: () => resetAmbientUser,
|
|
233
242
|
resolveUserId: () => resolveUserId,
|
|
234
|
-
shutdown: () => shutdown
|
|
243
|
+
shutdown: () => shutdown,
|
|
244
|
+
withSession: () => withSession
|
|
235
245
|
});
|
|
236
246
|
module.exports = __toCommonJS(tracing_exports);
|
|
237
247
|
|
|
@@ -502,6 +512,35 @@ function debugLog(message, ...args) {
|
|
|
502
512
|
}
|
|
503
513
|
}
|
|
504
514
|
|
|
515
|
+
// src/tracing/session.ts
|
|
516
|
+
var import_async_hooks2 = require("async_hooks");
|
|
517
|
+
var SESSION_ID_ATTRIBUTE = "gateway.session.id";
|
|
518
|
+
var currentSessionStorage = new import_async_hooks2.AsyncLocalStorage();
|
|
519
|
+
function getAmbientSessionId() {
|
|
520
|
+
return currentSessionStorage.getStore();
|
|
521
|
+
}
|
|
522
|
+
function withSession(sessionId, fn) {
|
|
523
|
+
return new Promise((resolve, reject) => {
|
|
524
|
+
currentSessionStorage.run(sessionId, () => {
|
|
525
|
+
Promise.resolve().then(fn).then(resolve, reject);
|
|
526
|
+
});
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
var SessionSpanProcessor = class {
|
|
530
|
+
onStart(span, _parentContext) {
|
|
531
|
+
const sessionId = getAmbientSessionId();
|
|
532
|
+
if (sessionId) {
|
|
533
|
+
span.setAttribute(SESSION_ID_ATTRIBUTE, sessionId);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
onEnd(_span) {
|
|
537
|
+
}
|
|
538
|
+
async shutdown() {
|
|
539
|
+
}
|
|
540
|
+
async forceFlush() {
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
|
|
505
544
|
// src/scores/index.ts
|
|
506
545
|
var import_api2 = require("@opentelemetry/api");
|
|
507
546
|
var SUCCESS_SIGNAL_KEY = "gateway.success.signal";
|
|
@@ -1037,6 +1076,7 @@ function buildProvider(config, logFn) {
|
|
|
1037
1076
|
}
|
|
1038
1077
|
}
|
|
1039
1078
|
spanProcessors.push(new IdentitySpanProcessor());
|
|
1079
|
+
spanProcessors.push(new SessionSpanProcessor());
|
|
1040
1080
|
const batchConfig = {};
|
|
1041
1081
|
if (config.batch?.maxQueueSize) {
|
|
1042
1082
|
batchConfig.maxQueueSize = config.batch.maxQueueSize;
|
|
@@ -1404,8 +1444,11 @@ async function* observeClaude(stream, options) {
|
|
|
1404
1444
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1405
1445
|
0 && (module.exports = {
|
|
1406
1446
|
IdentitySpanProcessor,
|
|
1447
|
+
SESSION_ID_ATTRIBUTE,
|
|
1448
|
+
SessionSpanProcessor,
|
|
1407
1449
|
USER_ID_ATTRIBUTE,
|
|
1408
1450
|
flush,
|
|
1451
|
+
getAmbientSessionId,
|
|
1409
1452
|
identify,
|
|
1410
1453
|
init,
|
|
1411
1454
|
initIsolated,
|
|
@@ -1417,6 +1460,7 @@ async function* observeClaude(stream, options) {
|
|
|
1417
1460
|
observeOpenAI,
|
|
1418
1461
|
resetAmbientUser,
|
|
1419
1462
|
resolveUserId,
|
|
1420
|
-
shutdown
|
|
1463
|
+
shutdown,
|
|
1464
|
+
withSession
|
|
1421
1465
|
});
|
|
1422
1466
|
//# sourceMappingURL=index.js.map
|