@mcoda/shared 0.1.113 → 0.1.115
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.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export * from "./mswarm/GenericJobContract.js";
|
|
|
12
12
|
export * from "./mswarm/CapabilityContract.js";
|
|
13
13
|
export * from "./mswarm/ArtifactSandboxContract.js";
|
|
14
14
|
export * from "./mswarm/LifecycleContract.js";
|
|
15
|
+
export * from "./mswarm/ClientProductContract.js";
|
|
15
16
|
export * from "./status/TaskStatus.js";
|
|
16
17
|
export type { BacklogLaneTotals, BacklogTotals, BacklogSummary, EffectiveVelocity, EstimateResult, EstimateDurations, EstimateEtas, EstimateStatusCounts, EstimateCompletionMetric, EstimateCompletion, VelocitySource, AgentHealth, AgentHealthStatus, AgentUsageLimitScope, AgentUsageLimitWindowType, AgentUsageLimitStatus, AgentUsageLimitRecord, UpsertAgentUsageLimitInput, RoutingDefaults, RoutingDefault, RoutingProvenance, RoutingCandidate, RoutingPreview, RoutingDefaultsUpdate, RefineTasksRequest, RefineTasksPlan, RefineTasksResult, RefineStrategy, RefineOperation, UpdateTaskOp, SplitTaskOp, MergeTasksOp, UpdateEstimateOp, UpdateInfo, UpdateChannel, ApplyUpdateResponse, } from "./openapi/OpenApiTypes.js";
|
|
17
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3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jB,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,mBAAmB,GACpB,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -12,4 +12,5 @@ export * from "./mswarm/GenericJobContract.js";
|
|
|
12
12
|
export * from "./mswarm/CapabilityContract.js";
|
|
13
13
|
export * from "./mswarm/ArtifactSandboxContract.js";
|
|
14
14
|
export * from "./mswarm/LifecycleContract.js";
|
|
15
|
+
export * from "./mswarm/ClientProductContract.js";
|
|
15
16
|
export * from "./status/TaskStatus.js";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The product a run is acting for, sent to mswarm as `x-mswarm-client-product`.
|
|
3
|
+
*
|
|
4
|
+
* This is deliberately separate from the client identity. The identity is the run's
|
|
5
|
+
* tenant slug and stays per-tenant, which is what mswarm attributes usage to. The
|
|
6
|
+
* product is what a self-hosted node can grant wholesale: a node that allowlists
|
|
7
|
+
* `okacam` admits every okacam tenant, so a multi-tenant product does not need one
|
|
8
|
+
* allowlist row per tenant added at provisioning time.
|
|
9
|
+
*
|
|
10
|
+
* mswarm never infers one from the other. A tenant whose slug happens to be `okacam`
|
|
11
|
+
* still reads as a client identity there, not as the product.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Resolves the product for a run.
|
|
15
|
+
*
|
|
16
|
+
* An explicit value from the host's run context wins; otherwise the deployment's
|
|
17
|
+
* `MSWARM_CLIENT_PRODUCT` is used. The env fallback is what lets a product enable this
|
|
18
|
+
* with one deployment variable and no code of its own, since each product runs its own
|
|
19
|
+
* codali instance.
|
|
20
|
+
*
|
|
21
|
+
* Returns undefined rather than throwing on a malformed value: failing to send an
|
|
22
|
+
* optional header must never take a run down. Node access simply falls back to whatever
|
|
23
|
+
* the client identity alone can reach.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveMswarmClientProduct(explicit?: string | null): string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* The header pair for a resolved product, or nothing when there is no usable product.
|
|
28
|
+
* Callers spread this next to the client-identity headers.
|
|
29
|
+
*/
|
|
30
|
+
export declare function mswarmClientProductHeaders(product: string | undefined | null): Record<string, string> | undefined;
|
|
31
|
+
//# sourceMappingURL=ClientProductContract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientProductContract.d.ts","sourceRoot":"","sources":["../../src/mswarm/ClientProductContract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAMvF;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GACjC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAGpC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The product a run is acting for, sent to mswarm as `x-mswarm-client-product`.
|
|
3
|
+
*
|
|
4
|
+
* This is deliberately separate from the client identity. The identity is the run's
|
|
5
|
+
* tenant slug and stays per-tenant, which is what mswarm attributes usage to. The
|
|
6
|
+
* product is what a self-hosted node can grant wholesale: a node that allowlists
|
|
7
|
+
* `okacam` admits every okacam tenant, so a multi-tenant product does not need one
|
|
8
|
+
* allowlist row per tenant added at provisioning time.
|
|
9
|
+
*
|
|
10
|
+
* mswarm never infers one from the other. A tenant whose slug happens to be `okacam`
|
|
11
|
+
* still reads as a client identity there, not as the product.
|
|
12
|
+
*/
|
|
13
|
+
/** Same shape mswarm accepts for a product entry: a single slug-like label. */
|
|
14
|
+
const CLIENT_PRODUCT_PATTERN = /^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$/i;
|
|
15
|
+
/**
|
|
16
|
+
* Resolves the product for a run.
|
|
17
|
+
*
|
|
18
|
+
* An explicit value from the host's run context wins; otherwise the deployment's
|
|
19
|
+
* `MSWARM_CLIENT_PRODUCT` is used. The env fallback is what lets a product enable this
|
|
20
|
+
* with one deployment variable and no code of its own, since each product runs its own
|
|
21
|
+
* codali instance.
|
|
22
|
+
*
|
|
23
|
+
* Returns undefined rather than throwing on a malformed value: failing to send an
|
|
24
|
+
* optional header must never take a run down. Node access simply falls back to whatever
|
|
25
|
+
* the client identity alone can reach.
|
|
26
|
+
*/
|
|
27
|
+
export function resolveMswarmClientProduct(explicit) {
|
|
28
|
+
const candidate = explicit?.trim() || process.env.MSWARM_CLIENT_PRODUCT?.trim();
|
|
29
|
+
if (!candidate || !CLIENT_PRODUCT_PATTERN.test(candidate)) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
return candidate.toLowerCase();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The header pair for a resolved product, or nothing when there is no usable product.
|
|
36
|
+
* Callers spread this next to the client-identity headers.
|
|
37
|
+
*/
|
|
38
|
+
export function mswarmClientProductHeaders(product) {
|
|
39
|
+
const value = resolveMswarmClientProduct(product);
|
|
40
|
+
return value ? { "x-mswarm-client-product": value } : undefined;
|
|
41
|
+
}
|