@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.mjs
CHANGED
|
@@ -16,7 +16,7 @@ var require_package = __commonJS({
|
|
|
16
16
|
"package.json"(exports, module) {
|
|
17
17
|
module.exports = {
|
|
18
18
|
name: "@withgateway/sdk",
|
|
19
|
-
version: "0.2.
|
|
19
|
+
version: "0.2.5",
|
|
20
20
|
description: "Gateway SDK for TypeScript - A/B experiments, tracing, and observability",
|
|
21
21
|
main: "./dist/index.js",
|
|
22
22
|
module: "./dist/index.mjs",
|
|
@@ -92,6 +92,11 @@ var require_package = __commonJS({
|
|
|
92
92
|
import: "./dist/traces/index.mjs",
|
|
93
93
|
require: "./dist/traces/index.js"
|
|
94
94
|
},
|
|
95
|
+
"./hooks": {
|
|
96
|
+
types: "./dist/hooks/index.d.ts",
|
|
97
|
+
import: "./dist/hooks/index.mjs",
|
|
98
|
+
require: "./dist/hooks/index.js"
|
|
99
|
+
},
|
|
95
100
|
"./cli": {
|
|
96
101
|
types: "./dist/cli.d.ts",
|
|
97
102
|
import: "./dist/cli.mjs",
|
|
@@ -115,6 +120,7 @@ var require_package = __commonJS({
|
|
|
115
120
|
"typecheck:examples": "tsc -p tsconfig.examples.json --noEmit",
|
|
116
121
|
test: "vitest",
|
|
117
122
|
"test:run": "vitest run",
|
|
123
|
+
"test:integration": "vitest run --config vitest.integration.config.ts",
|
|
118
124
|
lint: "eslint src --ext .ts",
|
|
119
125
|
clean: "rm -rf dist",
|
|
120
126
|
example: "tsx examples/test-ab-experiment.ts",
|
|
@@ -472,6 +478,35 @@ function debugLog(message, ...args) {
|
|
|
472
478
|
}
|
|
473
479
|
}
|
|
474
480
|
|
|
481
|
+
// src/tracing/session.ts
|
|
482
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
483
|
+
var SESSION_ID_ATTRIBUTE = "gateway.session.id";
|
|
484
|
+
var currentSessionStorage = new AsyncLocalStorage2();
|
|
485
|
+
function getAmbientSessionId() {
|
|
486
|
+
return currentSessionStorage.getStore();
|
|
487
|
+
}
|
|
488
|
+
function withSession(sessionId, fn) {
|
|
489
|
+
return new Promise((resolve, reject) => {
|
|
490
|
+
currentSessionStorage.run(sessionId, () => {
|
|
491
|
+
Promise.resolve().then(fn).then(resolve, reject);
|
|
492
|
+
});
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
var SessionSpanProcessor = class {
|
|
496
|
+
onStart(span, _parentContext) {
|
|
497
|
+
const sessionId = getAmbientSessionId();
|
|
498
|
+
if (sessionId) {
|
|
499
|
+
span.setAttribute(SESSION_ID_ATTRIBUTE, sessionId);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
onEnd(_span) {
|
|
503
|
+
}
|
|
504
|
+
async shutdown() {
|
|
505
|
+
}
|
|
506
|
+
async forceFlush() {
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
|
|
475
510
|
// src/scores/index.ts
|
|
476
511
|
import { isSpanContextValid as isSpanContextValid2, trace as trace2 } from "@opentelemetry/api";
|
|
477
512
|
var SUCCESS_SIGNAL_KEY = "gateway.success.signal";
|
|
@@ -1007,6 +1042,7 @@ function buildProvider(config, logFn) {
|
|
|
1007
1042
|
}
|
|
1008
1043
|
}
|
|
1009
1044
|
spanProcessors.push(new IdentitySpanProcessor());
|
|
1045
|
+
spanProcessors.push(new SessionSpanProcessor());
|
|
1010
1046
|
const batchConfig = {};
|
|
1011
1047
|
if (config.batch?.maxQueueSize) {
|
|
1012
1048
|
batchConfig.maxQueueSize = config.batch.maxQueueSize;
|
|
@@ -1377,8 +1413,11 @@ async function* observeClaude(stream, options) {
|
|
|
1377
1413
|
}
|
|
1378
1414
|
export {
|
|
1379
1415
|
IdentitySpanProcessor,
|
|
1416
|
+
SESSION_ID_ATTRIBUTE,
|
|
1417
|
+
SessionSpanProcessor,
|
|
1380
1418
|
USER_ID_ATTRIBUTE,
|
|
1381
1419
|
flush,
|
|
1420
|
+
getAmbientSessionId,
|
|
1382
1421
|
identify,
|
|
1383
1422
|
init,
|
|
1384
1423
|
initIsolated,
|
|
@@ -1390,6 +1429,7 @@ export {
|
|
|
1390
1429
|
observeOpenAI,
|
|
1391
1430
|
resetAmbientUser,
|
|
1392
1431
|
resolveUserId,
|
|
1393
|
-
shutdown
|
|
1432
|
+
shutdown,
|
|
1433
|
+
withSession
|
|
1394
1434
|
};
|
|
1395
1435
|
//# sourceMappingURL=index.mjs.map
|