@axiom-lattice/client-sdk 3.0.1 → 3.0.2
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/__tests__/workspaceContext.test.d.ts +10 -0
- package/dist/__tests__/workspaceContext.test.d.ts.map +1 -0
- package/dist/__tests__/workspaceContext.test.js +112 -0
- package/dist/__tests__/workspaceContext.test.js.map +1 -0
- package/dist/abstract-client.d.ts +8 -0
- package/dist/abstract-client.d.ts.map +1 -1
- package/dist/abstract-client.js +12 -0
- package/dist/abstract-client.js.map +1 -1
- package/dist/client.d.ts +17 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +44 -11
- package/dist/client.js.map +1 -1
- package/dist/eval.d.ts +8 -1
- package/dist/eval.d.ts.map +1 -1
- package/dist/eval.js +8 -1
- package/dist/eval.js.map +1 -1
- package/dist/index.d.ts +33 -4
- package/dist/index.js +59 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1864,6 +1864,14 @@ var AbstractClient = class {
|
|
|
1864
1864
|
constructor(config) {
|
|
1865
1865
|
this.tenantId = "";
|
|
1866
1866
|
this.registeredTools = /* @__PURE__ */ new Map();
|
|
1867
|
+
/**
|
|
1868
|
+
* Workspace/project headers for THIS instance. Clones share this object
|
|
1869
|
+
* with their parent (see {@link clone}), so workspace-context changes on
|
|
1870
|
+
* any client of the same family propagate to all sibling clones — e.g.
|
|
1871
|
+
* a scoped WorkspaceContextProvider syncing the "__GLOBAL__" client also
|
|
1872
|
+
* updates every per-assistant chat client created from the same base.
|
|
1873
|
+
*/
|
|
1874
|
+
this.workspaceHeaders = {};
|
|
1867
1875
|
/**
|
|
1868
1876
|
* Chat namespace for sending messages and streaming responses
|
|
1869
1877
|
*/
|
|
@@ -2736,6 +2744,7 @@ var AbstractClient = class {
|
|
|
2736
2744
|
...overrides
|
|
2737
2745
|
};
|
|
2738
2746
|
const clonedClient = this.createInstance(clonedConfig);
|
|
2747
|
+
clonedClient.workspaceHeaders = this.workspaceHeaders;
|
|
2739
2748
|
if (this.tenantId) {
|
|
2740
2749
|
clonedClient.setTenantId(this.tenantId);
|
|
2741
2750
|
}
|
|
@@ -2948,7 +2957,14 @@ var EvalClient = class {
|
|
|
2948
2957
|
}
|
|
2949
2958
|
};
|
|
2950
2959
|
this.runs = {
|
|
2951
|
-
|
|
2960
|
+
/**
|
|
2961
|
+
* Start an eval run. Optional runConfig carries the workspace-project
|
|
2962
|
+
* environment (caller's runConfig) the run executes in.
|
|
2963
|
+
*/
|
|
2964
|
+
start: (projectId, runConfig) => this.request(`/api/eval/projects/${projectId}/runs`, {
|
|
2965
|
+
method: "POST",
|
|
2966
|
+
body: runConfig ? JSON.stringify({ runConfig }) : void 0
|
|
2967
|
+
}),
|
|
2952
2968
|
list: (opts) => {
|
|
2953
2969
|
const params = new URLSearchParams();
|
|
2954
2970
|
if (opts?.projectId)
|
|
@@ -3105,7 +3121,7 @@ var _Client = class extends AbstractClient {
|
|
|
3105
3121
|
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
3106
3122
|
try {
|
|
3107
3123
|
const fullUrl = url.startsWith("http") ? url : `${this.config.baseURL}${url}`;
|
|
3108
|
-
const workspaceHeaders =
|
|
3124
|
+
const workspaceHeaders = this.getWorkspaceHeaders();
|
|
3109
3125
|
const mergedHeaders = {
|
|
3110
3126
|
...this.headers,
|
|
3111
3127
|
...workspaceHeaders,
|
|
@@ -3140,31 +3156,62 @@ var _Client = class extends AbstractClient {
|
|
|
3140
3156
|
this.headers["x-tenant-id"] = tenantId;
|
|
3141
3157
|
}
|
|
3142
3158
|
/**
|
|
3143
|
-
* Set workspace and project headers for
|
|
3159
|
+
* Set workspace and project headers for THIS client instance.
|
|
3160
|
+
* Instance-scoped: each Client instance carries its own context, so
|
|
3161
|
+
* nested page-level containers get isolated headers.
|
|
3162
|
+
* @param workspaceId - Workspace identifier
|
|
3163
|
+
* @param projectId - Project identifier
|
|
3164
|
+
*/
|
|
3165
|
+
setWorkspaceContext(workspaceId, projectId) {
|
|
3166
|
+
if (workspaceId !== void 0) {
|
|
3167
|
+
if (workspaceId) {
|
|
3168
|
+
this.workspaceHeaders["x-workspace-id"] = workspaceId;
|
|
3169
|
+
} else {
|
|
3170
|
+
delete this.workspaceHeaders["x-workspace-id"];
|
|
3171
|
+
}
|
|
3172
|
+
}
|
|
3173
|
+
if (projectId !== void 0) {
|
|
3174
|
+
if (projectId) {
|
|
3175
|
+
this.workspaceHeaders["x-project-id"] = projectId;
|
|
3176
|
+
} else {
|
|
3177
|
+
delete this.workspaceHeaders["x-project-id"];
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
}
|
|
3181
|
+
/**
|
|
3182
|
+
* Set workspace and project headers globally (legacy static API).
|
|
3183
|
+
* Used by callers without a client instance. Affects all instances
|
|
3184
|
+
* that fall back to global headers.
|
|
3144
3185
|
* @param workspaceId - Workspace identifier
|
|
3145
3186
|
* @param projectId - Project identifier
|
|
3146
3187
|
*/
|
|
3147
3188
|
static setWorkspaceContext(workspaceId, projectId) {
|
|
3148
3189
|
if (workspaceId !== void 0) {
|
|
3149
3190
|
if (workspaceId) {
|
|
3150
|
-
_Client.
|
|
3191
|
+
_Client.globalWorkspaceHeaders["x-workspace-id"] = workspaceId;
|
|
3151
3192
|
} else {
|
|
3152
|
-
delete _Client.
|
|
3193
|
+
delete _Client.globalWorkspaceHeaders["x-workspace-id"];
|
|
3153
3194
|
}
|
|
3154
3195
|
}
|
|
3155
3196
|
if (projectId !== void 0) {
|
|
3156
3197
|
if (projectId) {
|
|
3157
|
-
_Client.
|
|
3198
|
+
_Client.globalWorkspaceHeaders["x-project-id"] = projectId;
|
|
3158
3199
|
} else {
|
|
3159
|
-
delete _Client.
|
|
3200
|
+
delete _Client.globalWorkspaceHeaders["x-project-id"];
|
|
3160
3201
|
}
|
|
3161
3202
|
}
|
|
3162
3203
|
}
|
|
3163
3204
|
/**
|
|
3164
|
-
* Get
|
|
3205
|
+
* Get workspace headers for THIS instance (merged with global fallback)
|
|
3206
|
+
*/
|
|
3207
|
+
getWorkspaceHeaders() {
|
|
3208
|
+
return { ..._Client.globalWorkspaceHeaders, ...this.workspaceHeaders };
|
|
3209
|
+
}
|
|
3210
|
+
/**
|
|
3211
|
+
* Get global workspace headers (legacy static API)
|
|
3165
3212
|
*/
|
|
3166
3213
|
static getWorkspaceHeaders() {
|
|
3167
|
-
return { ..._Client.
|
|
3214
|
+
return { ..._Client.globalWorkspaceHeaders };
|
|
3168
3215
|
}
|
|
3169
3216
|
/**
|
|
3170
3217
|
* Creates a new instance of the client with the given configuration
|
|
@@ -3182,7 +3229,7 @@ var _Client = class extends AbstractClient {
|
|
|
3182
3229
|
*/
|
|
3183
3230
|
async makeRequest(url, options) {
|
|
3184
3231
|
const method = options?.method || "GET";
|
|
3185
|
-
const workspaceHeaders =
|
|
3232
|
+
const workspaceHeaders = this.getWorkspaceHeaders();
|
|
3186
3233
|
const requestHeaders = {
|
|
3187
3234
|
...this.headers,
|
|
3188
3235
|
...workspaceHeaders,
|
|
@@ -3317,7 +3364,7 @@ var _Client = class extends AbstractClient {
|
|
|
3317
3364
|
* @private
|
|
3318
3365
|
*/
|
|
3319
3366
|
getAllHeaders() {
|
|
3320
|
-
const workspaceHeaders =
|
|
3367
|
+
const workspaceHeaders = this.getWorkspaceHeaders();
|
|
3321
3368
|
return {
|
|
3322
3369
|
...this.headers,
|
|
3323
3370
|
...workspaceHeaders
|
|
@@ -3414,7 +3461,7 @@ var _Client = class extends AbstractClient {
|
|
|
3414
3461
|
}
|
|
3415
3462
|
};
|
|
3416
3463
|
var Client = _Client;
|
|
3417
|
-
Client.
|
|
3464
|
+
Client.globalWorkspaceHeaders = {};
|
|
3418
3465
|
|
|
3419
3466
|
// src/wechat-client.ts
|
|
3420
3467
|
var import_encoding = __toESM(require_encoding());
|