@withgateway/sdk 0.2.3 → 0.2.4
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 +12557 -5244
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +12557 -5244
- package/dist/cli.mjs.map +1 -1
- package/dist/files/index.js +65 -29
- package/dist/files/index.js.map +1 -1
- package/dist/files/index.mjs +53 -18
- 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 +6538 -1549
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6628 -1652
- package/dist/index.mjs.map +1 -1
- package/dist/traces/index.js +54 -18
- package/dist/traces/index.js.map +1 -1
- package/dist/traces/index.mjs +45 -10
- 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 +46 -3
- package/dist/tracing/index.js.map +1 -1
- package/dist/tracing/index.mjs +41 -2
- package/dist/tracing/index.mjs.map +1 -1
- package/dist/worlds/index.d.mts +365 -6
- package/dist/worlds/index.d.ts +365 -6
- package/dist/worlds/index.js +2037 -216
- package/dist/worlds/index.js.map +1 -1
- package/dist/worlds/index.mjs +2026 -205
- package/dist/worlds/index.mjs.map +1 -1
- package/package.json +6 -1
- package/runtime/gatewaysdk/environment/_materialize.py +3 -3
- package/runtime/gatewaysdk/environment/schema/api.py +116 -2
- package/runtime/gatewaysdk/environment/schema/compiler.py +14 -0
- package/runtime/gatewaysdk/environment/schema/host.py +37 -11
- package/runtime/gatewaysdk/environment/schema/skills/hooks-getting-started/SKILL.md +154 -0
- package/runtime/gatewaysdk/environment/schema/snapshot.py +6 -5
- package/runtime/gatewaysdk/environment/schema/tasks.py +12 -2
- package/runtime/gatewaysdk/environment/schema/workers.py +30 -13
- package/skills/hooks-getting-started/SKILL.md +154 -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.4",
|
|
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",
|
|
@@ -218,8 +223,11 @@ var require_package = __commonJS({
|
|
|
218
223
|
var tracing_exports = {};
|
|
219
224
|
__export(tracing_exports, {
|
|
220
225
|
IdentitySpanProcessor: () => IdentitySpanProcessor,
|
|
226
|
+
SESSION_ID_ATTRIBUTE: () => SESSION_ID_ATTRIBUTE,
|
|
227
|
+
SessionSpanProcessor: () => SessionSpanProcessor,
|
|
221
228
|
USER_ID_ATTRIBUTE: () => USER_ID_ATTRIBUTE,
|
|
222
229
|
flush: () => flush,
|
|
230
|
+
getAmbientSessionId: () => getAmbientSessionId,
|
|
223
231
|
identify: () => identify,
|
|
224
232
|
init: () => init,
|
|
225
233
|
initIsolated: () => initIsolated,
|
|
@@ -231,7 +239,8 @@ __export(tracing_exports, {
|
|
|
231
239
|
observeOpenAI: () => observeOpenAI,
|
|
232
240
|
resetAmbientUser: () => resetAmbientUser,
|
|
233
241
|
resolveUserId: () => resolveUserId,
|
|
234
|
-
shutdown: () => shutdown
|
|
242
|
+
shutdown: () => shutdown,
|
|
243
|
+
withSession: () => withSession
|
|
235
244
|
});
|
|
236
245
|
module.exports = __toCommonJS(tracing_exports);
|
|
237
246
|
|
|
@@ -502,6 +511,35 @@ function debugLog(message, ...args) {
|
|
|
502
511
|
}
|
|
503
512
|
}
|
|
504
513
|
|
|
514
|
+
// src/tracing/session.ts
|
|
515
|
+
var import_async_hooks2 = require("async_hooks");
|
|
516
|
+
var SESSION_ID_ATTRIBUTE = "gateway.session.id";
|
|
517
|
+
var currentSessionStorage = new import_async_hooks2.AsyncLocalStorage();
|
|
518
|
+
function getAmbientSessionId() {
|
|
519
|
+
return currentSessionStorage.getStore();
|
|
520
|
+
}
|
|
521
|
+
function withSession(sessionId, fn) {
|
|
522
|
+
return new Promise((resolve, reject) => {
|
|
523
|
+
currentSessionStorage.run(sessionId, () => {
|
|
524
|
+
Promise.resolve().then(fn).then(resolve, reject);
|
|
525
|
+
});
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
var SessionSpanProcessor = class {
|
|
529
|
+
onStart(span, _parentContext) {
|
|
530
|
+
const sessionId = getAmbientSessionId();
|
|
531
|
+
if (sessionId) {
|
|
532
|
+
span.setAttribute(SESSION_ID_ATTRIBUTE, sessionId);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
onEnd(_span) {
|
|
536
|
+
}
|
|
537
|
+
async shutdown() {
|
|
538
|
+
}
|
|
539
|
+
async forceFlush() {
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
|
|
505
543
|
// src/scores/index.ts
|
|
506
544
|
var import_api2 = require("@opentelemetry/api");
|
|
507
545
|
var SUCCESS_SIGNAL_KEY = "gateway.success.signal";
|
|
@@ -1037,6 +1075,7 @@ function buildProvider(config, logFn) {
|
|
|
1037
1075
|
}
|
|
1038
1076
|
}
|
|
1039
1077
|
spanProcessors.push(new IdentitySpanProcessor());
|
|
1078
|
+
spanProcessors.push(new SessionSpanProcessor());
|
|
1040
1079
|
const batchConfig = {};
|
|
1041
1080
|
if (config.batch?.maxQueueSize) {
|
|
1042
1081
|
batchConfig.maxQueueSize = config.batch.maxQueueSize;
|
|
@@ -1404,8 +1443,11 @@ async function* observeClaude(stream, options) {
|
|
|
1404
1443
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1405
1444
|
0 && (module.exports = {
|
|
1406
1445
|
IdentitySpanProcessor,
|
|
1446
|
+
SESSION_ID_ATTRIBUTE,
|
|
1447
|
+
SessionSpanProcessor,
|
|
1407
1448
|
USER_ID_ATTRIBUTE,
|
|
1408
1449
|
flush,
|
|
1450
|
+
getAmbientSessionId,
|
|
1409
1451
|
identify,
|
|
1410
1452
|
init,
|
|
1411
1453
|
initIsolated,
|
|
@@ -1417,6 +1459,7 @@ async function* observeClaude(stream, options) {
|
|
|
1417
1459
|
observeOpenAI,
|
|
1418
1460
|
resetAmbientUser,
|
|
1419
1461
|
resolveUserId,
|
|
1420
|
-
shutdown
|
|
1462
|
+
shutdown,
|
|
1463
|
+
withSession
|
|
1421
1464
|
});
|
|
1422
1465
|
//# sourceMappingURL=index.js.map
|