@antasphere/chassis-contract 0.0.0-stage → 1.0.1
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/LICENSE +82 -0
- package/dist/define.d.ts +177 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +35 -0
- package/dist/define.js.map +1 -0
- package/dist/entitlements.d.ts +265 -0
- package/dist/entitlements.d.ts.map +1 -0
- package/dist/entitlements.js +155 -0
- package/dist/entitlements.js.map +1 -0
- package/dist/identity.d.ts +56 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +2 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/routes/index.d.ts +5403 -0
- package/dist/routes/index.d.ts.map +1 -0
- package/dist/routes/index.js +940 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/schemas/api-keys.d.ts +54 -0
- package/dist/schemas/api-keys.d.ts.map +1 -0
- package/dist/schemas/api-keys.js +48 -0
- package/dist/schemas/api-keys.js.map +1 -0
- package/dist/schemas/audit.d.ts +74 -0
- package/dist/schemas/audit.d.ts.map +1 -0
- package/dist/schemas/audit.js +65 -0
- package/dist/schemas/audit.js.map +1 -0
- package/dist/schemas/break-glass.d.ts +42 -0
- package/dist/schemas/break-glass.d.ts.map +1 -0
- package/dist/schemas/break-glass.js +38 -0
- package/dist/schemas/break-glass.js.map +1 -0
- package/dist/schemas/cli-auth.d.ts +59 -0
- package/dist/schemas/cli-auth.d.ts.map +1 -0
- package/dist/schemas/cli-auth.js +68 -0
- package/dist/schemas/cli-auth.js.map +1 -0
- package/dist/schemas/common.d.ts +96 -0
- package/dist/schemas/common.d.ts.map +1 -0
- package/dist/schemas/common.js +205 -0
- package/dist/schemas/common.js.map +1 -0
- package/dist/schemas/demo-passes.d.ts +90 -0
- package/dist/schemas/demo-passes.d.ts.map +1 -0
- package/dist/schemas/demo-passes.js +60 -0
- package/dist/schemas/demo-passes.js.map +1 -0
- package/dist/schemas/files.d.ts +39 -0
- package/dist/schemas/files.d.ts.map +1 -0
- package/dist/schemas/files.js +26 -0
- package/dist/schemas/files.js.map +1 -0
- package/dist/schemas/instance.d.ts +58 -0
- package/dist/schemas/instance.d.ts.map +1 -0
- package/dist/schemas/instance.js +70 -0
- package/dist/schemas/instance.js.map +1 -0
- package/dist/schemas/invitations.d.ts +100 -0
- package/dist/schemas/invitations.d.ts.map +1 -0
- package/dist/schemas/invitations.js +55 -0
- package/dist/schemas/invitations.js.map +1 -0
- package/dist/schemas/me.d.ts +81 -0
- package/dist/schemas/me.d.ts.map +1 -0
- package/dist/schemas/me.js +178 -0
- package/dist/schemas/me.js.map +1 -0
- package/dist/schemas/members.d.ts +60 -0
- package/dist/schemas/members.d.ts.map +1 -0
- package/dist/schemas/members.js +43 -0
- package/dist/schemas/members.js.map +1 -0
- package/dist/schemas/projects.d.ts +232 -0
- package/dist/schemas/projects.d.ts.map +1 -0
- package/dist/schemas/projects.js +140 -0
- package/dist/schemas/projects.js.map +1 -0
- package/dist/schemas/scope.d.ts +14 -0
- package/dist/schemas/scope.d.ts.map +1 -0
- package/dist/schemas/scope.js +5 -0
- package/dist/schemas/scope.js.map +1 -0
- package/dist/schemas/setup.d.ts +28 -0
- package/dist/schemas/setup.d.ts.map +1 -0
- package/dist/schemas/setup.js +28 -0
- package/dist/schemas/setup.js.map +1 -0
- package/dist/schemas/sso-connect.d.ts +30 -0
- package/dist/schemas/sso-connect.d.ts.map +1 -0
- package/dist/schemas/sso-connect.js +38 -0
- package/dist/schemas/sso-connect.js.map +1 -0
- package/dist/schemas/sso-logout.d.ts +17 -0
- package/dist/schemas/sso-logout.d.ts.map +1 -0
- package/dist/schemas/sso-logout.js +16 -0
- package/dist/schemas/sso-logout.js.map +1 -0
- package/dist/schemas/teams.d.ts +100 -0
- package/dist/schemas/teams.d.ts.map +1 -0
- package/dist/schemas/teams.js +84 -0
- package/dist/schemas/teams.js.map +1 -0
- package/dist/schemas/workspaces.d.ts +99 -0
- package/dist/schemas/workspaces.d.ts.map +1 -0
- package/dist/schemas/workspaces.js +96 -0
- package/dist/schemas/workspaces.js.map +1 -0
- package/dist/seams.d.ts +185 -0
- package/dist/seams.d.ts.map +1 -0
- package/dist/seams.js +37 -0
- package/dist/seams.js.map +1 -0
- package/package.json +41 -3
- package/src/define.ts +64 -0
- package/src/entitlements.ts +340 -0
- package/src/identity.ts +49 -0
- package/src/index.ts +37 -0
- package/src/routes/index.ts +1146 -0
- package/src/schemas/api-keys.ts +53 -0
- package/src/schemas/audit.ts +74 -0
- package/src/schemas/break-glass.ts +46 -0
- package/src/schemas/cli-auth.ts +78 -0
- package/src/schemas/common.ts +206 -0
- package/src/schemas/demo-passes.ts +73 -0
- package/src/schemas/files.ts +30 -0
- package/src/schemas/instance.ts +71 -0
- package/src/schemas/invitations.ts +66 -0
- package/src/schemas/me.ts +184 -0
- package/src/schemas/members.ts +53 -0
- package/src/schemas/projects.ts +174 -0
- package/src/schemas/scope.ts +18 -0
- package/src/schemas/setup.ts +31 -0
- package/src/schemas/sso-connect.ts +40 -0
- package/src/schemas/sso-logout.ts +17 -0
- package/src/schemas/teams.ts +101 -0
- package/src/schemas/workspaces.ts +109 -0
- package/src/seams.ts +202 -0
- package/test/define.test.ts +59 -0
- package/README.md +0 -3
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BILLING_PLANS, billingPlanSchema } from '@antasphere/contract';
|
|
3
|
+
/**
|
|
4
|
+
* The billing rail's declaration layer (the pay-per-use billing rail spec,
|
|
5
|
+
* §7 and §8b): a route says ONCE, next to its contract, what it meters, which
|
|
6
|
+
* limit it checks and which feature it needs. One chassis middleware reads
|
|
7
|
+
* the declaration and enforces it for every client of `/api/v1` at once (the
|
|
8
|
+
* dashboard, the CLI and the MCP tools are all HTTP clients of it), and a
|
|
9
|
+
* handler never checks or emits by hand.
|
|
10
|
+
*
|
|
11
|
+
* Client-safe on purpose: no Hono here. A route is referenced by its
|
|
12
|
+
* `{ method, path }` as the OpenAPI helper spells it (`{id}` params), so the
|
|
13
|
+
* tool's contract builds the registry from its route objects and the SDK can
|
|
14
|
+
* read the same declarations without pulling the server.
|
|
15
|
+
*/
|
|
16
|
+
// ── The hub's half: the messages the tool exchanges with the hub ──────────
|
|
17
|
+
//
|
|
18
|
+
// The hub owns these shapes and publishes them as `@antasphere/contract`
|
|
19
|
+
// (the hub's own contract package, on npm at the hub's version); this file
|
|
20
|
+
// re-exports them under the names the chassis has always used, so a tool
|
|
21
|
+
// reads exactly what the hub wrote and a change at the hub reaches every
|
|
22
|
+
// tool through one dependency bump (PRDCT-3325; before it, a hand copy checked
|
|
23
|
+
// against the hub's wire snapshot). The chassis's OWN half — the
|
|
24
|
+
// declaration layer below — stays here.
|
|
25
|
+
export { BILLING_PLANS, USAGE_CHECK_REASONS, USAGE_EVENT_MAX_FUTURE_MS, USAGE_EVENT_MAX_PAST_MS, USAGE_EVENTS_BATCH_MAX, USAGE_REJECT_REASONS, USAGE_ROUTE_ERRORS, USAGE_WRITE_SCOPE, usageCheckRequestSchema, usageCheckSchema, usageEventOccurrenceIssue, usageEventResultSchema, usageEventSchema, usageEventsBatchSchema, usageIngestResultSchema, usageRejectReasonSchema } from '@antasphere/contract';
|
|
26
|
+
/**
|
|
27
|
+
* The plan tiers, a CLOSED enum the hub owns (`BILLING_PLANS` in
|
|
28
|
+
* `@antasphere/contract`), under the chassis's own names (§8b): `free` is the
|
|
29
|
+
* default with no subscription; `pro` is the paid plan. "Enterprise" is not
|
|
30
|
+
* a tier but a per-account override the hub serves.
|
|
31
|
+
*/
|
|
32
|
+
export const ENTITLEMENT_TIERS = BILLING_PLANS;
|
|
33
|
+
export const entitlementTierSchema = billingPlanSchema;
|
|
34
|
+
/** The wire code of a credit refusal (§7 step 4), and its `details`. */
|
|
35
|
+
export const ENTITLEMENT_DENIED = 'entitlement_denied';
|
|
36
|
+
/** The key of a route's feature declaration, whichever shape it uses; null when none. */
|
|
37
|
+
export function featureKeyOf(entry) {
|
|
38
|
+
if (!entry.feature)
|
|
39
|
+
return null;
|
|
40
|
+
return typeof entry.feature === 'string' ? entry.feature : entry.feature.key;
|
|
41
|
+
}
|
|
42
|
+
/** The actor hook of a route, the entry's own or its meter's; null when the principal is the actor. */
|
|
43
|
+
export function actorHookOf(entry) {
|
|
44
|
+
return entry.actor ?? entry.meter?.actor ?? null;
|
|
45
|
+
}
|
|
46
|
+
/** `METHOD /path` — the registry key of a route. */
|
|
47
|
+
export function routeEntitlementKey(route) {
|
|
48
|
+
return `${route.method.toUpperCase()} ${route.path}`;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Build the registry from the tool's route objects. One entry per route: a
|
|
52
|
+
* second declaration of the same route throws at module load, so a typo or a
|
|
53
|
+
* copy cannot silently double or replace a price.
|
|
54
|
+
*/
|
|
55
|
+
export function declareRouteEntitlements(entries) {
|
|
56
|
+
const map = new Map();
|
|
57
|
+
for (const entry of entries) {
|
|
58
|
+
const key = routeEntitlementKey(entry.route);
|
|
59
|
+
if (map.has(key))
|
|
60
|
+
throw new Error(`route entitlement declared twice: ${key}`);
|
|
61
|
+
if (!entry.meter && !entry.limit && !entry.feature) {
|
|
62
|
+
throw new Error(`route entitlement declares nothing: ${key}`);
|
|
63
|
+
}
|
|
64
|
+
map.set(key, entry);
|
|
65
|
+
}
|
|
66
|
+
return map;
|
|
67
|
+
}
|
|
68
|
+
/** The declared body size of a request (its `Content-Length`), 0 when absent or malformed. */
|
|
69
|
+
export function declaredContentLength(ctx) {
|
|
70
|
+
const n = Number(ctx.headers.get('content-length') ?? '0');
|
|
71
|
+
return Number.isFinite(n) && n > 0 ? n : 0;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The stored size a handler recorded in its audit metadata (`sizeBytes`),
|
|
75
|
+
* falling back to the declared body size before the handler ran. The check
|
|
76
|
+
* sees the declared size, the emit sees the bytes that were actually kept.
|
|
77
|
+
*/
|
|
78
|
+
export function auditedSizeBytes(ctx) {
|
|
79
|
+
const stored = ctx.audit?.metadata?.sizeBytes;
|
|
80
|
+
if (typeof stored === 'number' && Number.isFinite(stored) && stored >= 0)
|
|
81
|
+
return stored;
|
|
82
|
+
return declaredContentLength(ctx);
|
|
83
|
+
}
|
|
84
|
+
// ── The tool's declared defaults, as `GET /instance` shows them ────────────
|
|
85
|
+
/**
|
|
86
|
+
* A priced action: the default the hub seeds its price book from (§7); the
|
|
87
|
+
* hub's rows win afterwards. `creditsPerUnit` credits buy `per` units of
|
|
88
|
+
* `unit` (`per` defaults to 1): an action metered in bytes and priced per
|
|
89
|
+
* mebibyte declares `{ creditsPerUnit: 5, unit: 'bytes', per: 1048576 }`,
|
|
90
|
+
* so the meter stays exact, the price reads as the seed table says it, and
|
|
91
|
+
* the two agree by construction (PRDCT-2627: the boot refuses a route whose
|
|
92
|
+
* meter unit differs from its action's). The hub prices an event as
|
|
93
|
+
* `creditsPerUnit × quantity / per`; rounding a fraction of a credit is the
|
|
94
|
+
* hub's rule, not the tool's.
|
|
95
|
+
*/
|
|
96
|
+
export const entitlementActionSchema = z.object({
|
|
97
|
+
key: z.string().min(1),
|
|
98
|
+
creditsPerUnit: z.number().int().min(0),
|
|
99
|
+
unit: z.string().min(1),
|
|
100
|
+
/** How many units one `creditsPerUnit` buys; 1 when absent. */
|
|
101
|
+
per: z.number().int().min(1).optional(),
|
|
102
|
+
label: z.string().min(1)
|
|
103
|
+
});
|
|
104
|
+
/**
|
|
105
|
+
* The credits an action declares for a quantity: `creditsPerUnit × quantity
|
|
106
|
+
* / per`, exact (a fraction is the hub's to round). A test pins the seed
|
|
107
|
+
* values with it, so a unit slip (5 per byte where 5 per MB was meant)
|
|
108
|
+
* fails before the price book is seeded from discovery.
|
|
109
|
+
*/
|
|
110
|
+
export function declaredCredits(action, quantity) {
|
|
111
|
+
return (action.creditsPerUnit * quantity) / (action.per ?? 1);
|
|
112
|
+
}
|
|
113
|
+
/** A limit's value per tier plus the oss value (the operator's own knob); null = unlimited. */
|
|
114
|
+
export const tierLimitSchema = z.object({
|
|
115
|
+
oss: z.number().nullable(),
|
|
116
|
+
free: z.number().nullable(),
|
|
117
|
+
pro: z.number().nullable()
|
|
118
|
+
});
|
|
119
|
+
/** A feature's switch per tier (oss has every feature: a self-hosted instance knows no plan). */
|
|
120
|
+
export const tierFeatureSchema = z.object({
|
|
121
|
+
free: z.boolean(),
|
|
122
|
+
pro: z.boolean()
|
|
123
|
+
});
|
|
124
|
+
export const toolEntitlementsSchema = z.object({
|
|
125
|
+
actions: z.array(entitlementActionSchema),
|
|
126
|
+
limits: z.record(z.string(), tierLimitSchema),
|
|
127
|
+
features: z.record(z.string(), tierFeatureSchema)
|
|
128
|
+
});
|
|
129
|
+
/**
|
|
130
|
+
* The hub's answer to `GET /usage/entitlements?accountRef=` (§5): the hub's
|
|
131
|
+
* `usageEntitlementsSchema` (PRDCT-2636), the hub's own shape in
|
|
132
|
+
* snapshot (PRDCT-2677). The account's
|
|
133
|
+
* plan, resolved from the tier's defaults and the account's overrides; in
|
|
134
|
+
* phase 1 `limits` and `features` are empty and the tool's own declared
|
|
135
|
+
* values fill the numbers. A limit's value is a number or a boolean: the
|
|
136
|
+
* hub may switch a numeric limit off or on per account (`true` = unlimited,
|
|
137
|
+
* `false` = nothing allowed; `profiles.ts` resolves it so). Since phase 2
|
|
138
|
+
* (PRDCT-2663) the hub serves its real rows — every limit key it holds for
|
|
139
|
+
* the calling tool and the features on for the account — and `upgradeUrl`,
|
|
140
|
+
* its upgrade page for the organization carrying `org`, `tool` and `plan`;
|
|
141
|
+
* the chassis appends `&key=<key>&requiredPlan=<tier>` at refusal time.
|
|
142
|
+
* Required: every hub since 0.11.0 sends it.
|
|
143
|
+
*/
|
|
144
|
+
export const entitlementProfileSchema = z.object({
|
|
145
|
+
accountRef: z.uuid(),
|
|
146
|
+
plan: entitlementTierSchema,
|
|
147
|
+
/** Until when the plan is paid for (ISO 8601); null on `free` and on a live subscription. */
|
|
148
|
+
planUntil: z.string().nullable(),
|
|
149
|
+
limits: z.record(z.string(), z.union([z.number(), z.boolean()])),
|
|
150
|
+
features: z.array(z.string()),
|
|
151
|
+
upgradeUrl: z.string()
|
|
152
|
+
});
|
|
153
|
+
/** The wire code of a plan refusal, and its `details` (§7 step 2). */
|
|
154
|
+
export const PLAN_REQUIRED = 'plan_required';
|
|
155
|
+
//# sourceMappingURL=entitlements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlements.js","sourceRoot":"","sources":["../src/entitlements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAoB,MAAM,sBAAsB,CAAC;AAG1F;;;;;;;;;;;;GAYG;AAEH,6EAA6E;AAC7E,EAAE;AACF,yEAAyE;AACzE,2EAA2E;AAC3E,yEAAyE;AACzE,yEAAyE;AACzE,+EAA+E;AAC/E,iEAAiE;AACjE,wCAAwC;AACxC,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,yBAAyB,EACzB,uBAAuB,EACvB,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,gBAAgB,EAChB,yBAAyB,EACzB,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,sBAAsB,CAAC;AAY9B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAE/C,MAAM,CAAC,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AAEvD,wEAAwE;AACxE,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAmHvD,yFAAyF;AACzF,MAAM,UAAU,YAAY,CAAC,KAAuB;IAClD,IAAI,CAAC,KAAK,CAAC,OAAO;QAAE,OAAO,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AE,CAAC;IAC7B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;CACvB,CAAC,CAAC;AAGH,sEAAsE;AACtE,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tool's IDENTITY: every value that names the tool where a person, an agent
|
|
3
|
+
* or an operator can see it. The chassis packages spell none of them; a tool
|
|
4
|
+
* writes ONE value of this type (in its own contract package, the one package
|
|
5
|
+
* its server, SDK, CLI and dashboard all depend on) and hands it to the three
|
|
6
|
+
* chassis entry points: `defineChassisContract` + `defineChassisRoutes` here,
|
|
7
|
+
* the server's `ToolDefinition.identity`, and the CLI's `defineCli`.
|
|
8
|
+
*
|
|
9
|
+
* Pure data, client-safe. The tool's domain WORDING (a refusal that names its
|
|
10
|
+
* resource) is not identity: it goes to the server's `copy` slot.
|
|
11
|
+
*/
|
|
12
|
+
export interface ToolIdentity<TScope extends string = string> {
|
|
13
|
+
/** Machine name, lower case (`acme`): the CLI's config namespace and its hub connect name. */
|
|
14
|
+
slug: string;
|
|
15
|
+
/** Human name (`Acme`): mails, the no-dashboard page, CLI messages, the name of an instance not set up yet. */
|
|
16
|
+
displayName: string;
|
|
17
|
+
/** API key prefix, without the underscore (`acm` mints `acm_<keyId>_<secret>`). Never change it once keys exist. */
|
|
18
|
+
apiKeyPrefix: string;
|
|
19
|
+
/** The scope vocabulary, by the part each scope plays. `dataExport` is the opt-in full-workspace export. */
|
|
20
|
+
scopes: {
|
|
21
|
+
read: TScope;
|
|
22
|
+
write: TScope;
|
|
23
|
+
dataExport: TScope;
|
|
24
|
+
};
|
|
25
|
+
/** How the OpenAPI document names the CLI key's grant (`things:read+write`). A literal: a contraction, not a join. */
|
|
26
|
+
cliKeyScopesLabel: string;
|
|
27
|
+
/**
|
|
28
|
+
* The tool's cloud home (PRDCT-2947): the instance Antasphere operates
|
|
29
|
+
* (`https://acme.antasphere.com`). The CLI resolves its URL there last
|
|
30
|
+
* (flag → env → profile → this), so `antasphere login` then `acme list`
|
|
31
|
+
* works on a clean machine; the implicit `cloud` profile lives at it. A
|
|
32
|
+
* self-hosted instance is named once, as a profile named for its host.
|
|
33
|
+
*/
|
|
34
|
+
cloud: {
|
|
35
|
+
url: string;
|
|
36
|
+
};
|
|
37
|
+
cli: {
|
|
38
|
+
/** The binary's name (`acme`). Must equal the `bin` key of the CLI's package.json. */
|
|
39
|
+
bin: string;
|
|
40
|
+
/** Prefix of the CLI's environment variables (`ACME` reads `ACME_URL`, `ACME_API_KEY`, `ACME_WORKSPACE`). */
|
|
41
|
+
envPrefix: string;
|
|
42
|
+
/** A pre-hub config directory still read once for migration (`~/.config/<dir>/config.json`). */
|
|
43
|
+
legacyConfigDir: string;
|
|
44
|
+
};
|
|
45
|
+
mcp: {
|
|
46
|
+
/** `serverInfo.name` of the bundled MCP server. */
|
|
47
|
+
serverName: string;
|
|
48
|
+
/** Prefix of the tool's MCP tool names, underscore included (`acme_`). The tool registers `<prefix>whoami`. */
|
|
49
|
+
toolPrefix: string;
|
|
50
|
+
};
|
|
51
|
+
/** OpenTelemetry `service.name`. */
|
|
52
|
+
otelServiceName: string;
|
|
53
|
+
/** The published container image. Read by nothing at run time: recorded so an instantiate script has one source. */
|
|
54
|
+
imageName: string;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,WAAW,YAAY,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM;IAC1D,8FAA8F;IAC9F,IAAI,EAAE,MAAM,CAAC;IACb,+GAA+G;IAC/G,WAAW,EAAE,MAAM,CAAC;IACpB,oHAAoH;IACpH,YAAY,EAAE,MAAM,CAAC;IACrB,4GAA4G;IAC5G,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5D,sHAAsH;IACtH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;;;;;OAMG;IACH,KAAK,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACvB,GAAG,EAAE;QACH,sFAAsF;QACtF,GAAG,EAAE,MAAM,CAAC;QACZ,6GAA6G;QAC7G,SAAS,EAAE,MAAM,CAAC;QAClB,gGAAgG;QAChG,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,GAAG,EAAE;QACH,mDAAmD;QACnD,UAAU,EAAE,MAAM,CAAC;QACnB,+GAA+G;QAC/G,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,oCAAoC;IACpC,eAAe,EAAE,MAAM,CAAC;IACxB,oHAAoH;IACpH,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
package/dist/identity.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export * from './schemas/common.js';
|
|
2
|
+
export * from './schemas/scope.js';
|
|
3
|
+
export * from './schemas/instance.js';
|
|
4
|
+
export * from './schemas/setup.js';
|
|
5
|
+
export { onboardingDismissedSchema, type OnboardingDismissed } from './schemas/me.js';
|
|
6
|
+
export * from './schemas/workspaces.js';
|
|
7
|
+
export * from './schemas/members.js';
|
|
8
|
+
export { cliAuthRequestSchema, cliAuthRequestedSchema, cliAuthCompleteSchema, cliAuthRevokedSchema, type CliAuthRequest, type CliAuthRequested, type CliAuthComplete, type CliAuthRevoked } from './schemas/cli-auth.js';
|
|
9
|
+
export * from './schemas/sso-connect.js';
|
|
10
|
+
export * from './schemas/sso-logout.js';
|
|
11
|
+
export * from './schemas/invitations.js';
|
|
12
|
+
export * from './schemas/audit.js';
|
|
13
|
+
export * from './schemas/break-glass.js';
|
|
14
|
+
export * from './schemas/files.js';
|
|
15
|
+
export * from './schemas/projects.js';
|
|
16
|
+
export * from './schemas/teams.js';
|
|
17
|
+
export * from './schemas/demo-passes.js';
|
|
18
|
+
export * from './seams.js';
|
|
19
|
+
export * from './entitlements.js';
|
|
20
|
+
export * from './define.js';
|
|
21
|
+
export type { ToolIdentity } from './identity.js';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,yBAAyB,EAAE,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtF,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Client-safe entry: pure zod schemas + seam types. No Hono anywhere on this
|
|
2
|
+
// path — the dashboard and SDK import from here and must stay server-free.
|
|
3
|
+
//
|
|
4
|
+
// The generic half of the platform contract. Everything is a static export
|
|
5
|
+
// EXCEPT what carries the tool's scope vocabulary: that comes out of
|
|
6
|
+
// `defineChassisContract({ scopes })`, instantiated once by the tool from its
|
|
7
|
+
// identity (`ToolIdentity`, ./identity.ts: the type only, the value is the tool's).
|
|
8
|
+
export * from './schemas/common.js';
|
|
9
|
+
export * from './schemas/scope.js';
|
|
10
|
+
export * from './schemas/instance.js';
|
|
11
|
+
export * from './schemas/setup.js';
|
|
12
|
+
export { onboardingDismissedSchema } from './schemas/me.js';
|
|
13
|
+
export * from './schemas/workspaces.js';
|
|
14
|
+
export * from './schemas/members.js';
|
|
15
|
+
export { cliAuthRequestSchema, cliAuthRequestedSchema, cliAuthCompleteSchema, cliAuthRevokedSchema } from './schemas/cli-auth.js';
|
|
16
|
+
export * from './schemas/sso-connect.js';
|
|
17
|
+
export * from './schemas/sso-logout.js';
|
|
18
|
+
export * from './schemas/invitations.js';
|
|
19
|
+
export * from './schemas/audit.js';
|
|
20
|
+
export * from './schemas/break-glass.js';
|
|
21
|
+
export * from './schemas/files.js';
|
|
22
|
+
export * from './schemas/projects.js';
|
|
23
|
+
export * from './schemas/teams.js';
|
|
24
|
+
export * from './schemas/demo-passes.js';
|
|
25
|
+
export * from './seams.js';
|
|
26
|
+
export * from './entitlements.js';
|
|
27
|
+
export * from './define.js';
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,2EAA2E;AAC3E,EAAE;AACF,2EAA2E;AAC3E,qEAAqE;AACrE,8EAA8E;AAC9E,oFAAoF;AACpF,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,yBAAyB,EAA4B,MAAM,iBAAiB,CAAC;AACtF,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EAKrB,MAAM,uBAAuB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC"}
|