@vibesdotdev/account 1.0.0-rc.4 → 1.0.0-rc.9

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.
Files changed (61) hide show
  1. package/dist/account/account-settings.storage.descriptor.d.ts +2 -0
  2. package/dist/account/account-settings.storage.descriptor.d.ts.map +1 -1
  3. package/dist/billing/internal/quota-client.d.ts +59 -0
  4. package/dist/billing/internal/quota-client.d.ts.map +1 -1
  5. package/dist/billing/internal/quota-client.js +113 -1
  6. package/dist/billing/internal/quota-client.js.map +1 -1
  7. package/dist/billing/overage/overage-policy.config.descriptor.d.ts +114 -0
  8. package/dist/billing/overage/overage-policy.config.descriptor.d.ts.map +1 -0
  9. package/dist/billing/overage/overage-policy.config.descriptor.js +52 -0
  10. package/dist/billing/overage/overage-policy.config.descriptor.js.map +1 -0
  11. package/dist/billing/overage/overage-policy.d.ts +159 -0
  12. package/dist/billing/overage/overage-policy.d.ts.map +1 -0
  13. package/dist/billing/overage/overage-policy.js +93 -0
  14. package/dist/billing/overage/overage-policy.js.map +1 -0
  15. package/dist/billing/usage/delivery.d.ts +96 -1
  16. package/dist/billing/usage/delivery.d.ts.map +1 -1
  17. package/dist/billing/usage/delivery.js +55 -0
  18. package/dist/billing/usage/delivery.js.map +1 -1
  19. package/dist/billing/usage/record-code-session-usage.d.ts +9 -2
  20. package/dist/billing/usage/record-code-session-usage.d.ts.map +1 -1
  21. package/dist/billing/usage/record-code-session-usage.js +4 -1
  22. package/dist/billing/usage/record-code-session-usage.js.map +1 -1
  23. package/dist/billing/usage/record-platform-resource.d.ts +14 -2
  24. package/dist/billing/usage/record-platform-resource.d.ts.map +1 -1
  25. package/dist/billing/usage/record-platform-resource.js +25 -6
  26. package/dist/billing/usage/record-platform-resource.js.map +1 -1
  27. package/dist/billing/usage/record-sandbox-uptime.d.ts +16 -3
  28. package/dist/billing/usage/record-sandbox-uptime.d.ts.map +1 -1
  29. package/dist/billing/usage/record-sandbox-uptime.js +24 -5
  30. package/dist/billing/usage/record-sandbox-uptime.js.map +1 -1
  31. package/dist/cli/plugin.d.ts.map +1 -1
  32. package/dist/cli/plugin.js +2 -0
  33. package/dist/cli/plugin.js.map +1 -1
  34. package/dist/org/account-org.plugin.d.ts +4 -5
  35. package/dist/org/account-org.plugin.d.ts.map +1 -1
  36. package/dist/org/account-org.plugin.js +5 -6
  37. package/dist/org/account-org.plugin.js.map +1 -1
  38. package/dist/org/orgId.context.descriptor.d.ts +2 -3
  39. package/dist/org/orgId.context.descriptor.d.ts.map +1 -1
  40. package/dist/org/orgId.context.descriptor.js +2 -3
  41. package/dist/org/orgId.context.descriptor.js.map +1 -1
  42. package/dist/org/orgId.context.impl.d.ts +5 -6
  43. package/dist/org/orgId.context.impl.d.ts.map +1 -1
  44. package/dist/org/orgId.context.impl.js +34 -8
  45. package/dist/org/orgId.context.impl.js.map +1 -1
  46. package/dist/plugin/billing-overage.d.ts +9 -0
  47. package/dist/plugin/billing-overage.d.ts.map +1 -0
  48. package/dist/plugin/billing-overage.js +17 -0
  49. package/dist/plugin/billing-overage.js.map +1 -0
  50. package/dist/plugin/index.d.ts.map +1 -1
  51. package/dist/plugin/index.js +5 -1
  52. package/dist/plugin/index.js.map +1 -1
  53. package/dist/system/account-system.config.descriptor.d.ts +17 -4
  54. package/dist/system/account-system.config.descriptor.d.ts.map +1 -1
  55. package/dist/system/account-system.config.descriptor.js +14 -2
  56. package/dist/system/account-system.config.descriptor.js.map +1 -1
  57. package/dist/system/config.d.ts +7 -2
  58. package/dist/system/config.d.ts.map +1 -1
  59. package/dist/system/config.js +15 -1
  60. package/dist/system/config.js.map +1 -1
  61. package/package.json +93 -18
@@ -18,11 +18,15 @@
18
18
  * Design constraints (same as record-generation-usage.ts)
19
19
  * - MUST NOT fail the heartbeat path. Always returns void; swallows
20
20
  * errors with structured log.
21
- * - MUST be time-bounded. 500ms hard cap via AbortController.
21
+ * - MUST be time-bounded. 500ms hard cap via AbortController, body
22
+ * read included.
23
+ * - A delivered record that could not be paid for is NOT success: the
24
+ * caller's `onOutcome` receives `shortfall` with the uncollected
25
+ * cost-basis USD.
22
26
  */
23
27
  import { getLogger } from '@vibesdotdev/logging';
24
28
  import { settle } from '@vibesdotdev/kernel';
25
- import { deliveryFailure, deliveryFailureMessage, notifyJournal } from "./delivery.js";
29
+ import { deliveryFailureMessage, notifyJournal, readUsageRecordDelivery, usageRecordSettlement } from "./delivery.js";
26
30
  function log(runtime) {
27
31
  return getLogger('account', runtime).child({ context: 'record-sandbox-uptime' });
28
32
  }
@@ -41,6 +45,7 @@ export function recordSandboxUptime(runtime, input) {
41
45
  // observe it. If the env stays bad, this dead-letters after
42
46
  // MAX_ATTEMPTS rather than sitting at `pending` indefinitely.
43
47
  void notifyJournal(log(runtime), 'recordSandboxUptime', () => input.journal?.onFailure?.({ reason: 'skip', message }));
48
+ void notifyJournal(log(runtime), 'recordSandboxUptime', () => input.onOutcome?.({ delivery: 'skipped', message }));
44
49
  return;
45
50
  }
46
51
  if (!input.accountOrigin) {
@@ -50,6 +55,7 @@ export function recordSandboxUptime(runtime, input) {
50
55
  reason: input.reason
51
56
  });
52
57
  void notifyJournal(log(runtime), 'recordSandboxUptime', () => input.journal?.onFailure?.({ reason: 'skip', message }));
58
+ void notifyJournal(log(runtime), 'recordSandboxUptime', () => input.onOutcome?.({ delivery: 'skipped', message }));
53
59
  return;
54
60
  }
55
61
  const accountOrigin = input.accountOrigin;
@@ -60,6 +66,7 @@ export function recordSandboxUptime(runtime, input) {
60
66
  reason: input.reason
61
67
  });
62
68
  void notifyJournal(log(runtime), 'recordSandboxUptime', () => input.journal?.onFailure?.({ reason: 'skip', message }));
69
+ void notifyJournal(log(runtime), 'recordSandboxUptime', () => input.onOutcome?.({ delivery: 'skipped', message }));
63
70
  return;
64
71
  }
65
72
  const serviceHeaders = {
@@ -100,12 +107,23 @@ export function recordSandboxUptime(runtime, input) {
100
107
  headers,
101
108
  body: JSON.stringify(fetchBody),
102
109
  signal
103
- }), { timeoutMs: USAGE_RECORD_TIMEOUT_MS, reason: 'account sandbox uptime usage record' })).then(async (delivered) => {
104
- const failure = deliveryFailure(delivered);
105
- if (!failure) {
110
+ }).then(readUsageRecordDelivery), { timeoutMs: USAGE_RECORD_TIMEOUT_MS, reason: 'account sandbox uptime usage record' })).then(async (settled) => {
111
+ const settlement = usageRecordSettlement(settled);
112
+ if (settlement.delivered) {
113
+ // Delivered, so the journal row is done even when the charge was
114
+ // not collected: re-sending would write the usage row twice.
106
115
  await notifyJournal(log(runtime), 'recordSandboxUptime', input.journal?.onSuccess);
116
+ const { outcome } = settlement;
117
+ if (outcome.status !== 'charged') {
118
+ log(runtime).warn('recordSandboxUptime: usage delivered but not charged in full', {
119
+ hostId: input.hostId,
120
+ outcome
121
+ });
122
+ }
123
+ await notifyJournal(log(runtime), 'recordSandboxUptime', () => input.onOutcome?.({ delivery: 'delivered', outcome }));
107
124
  return;
108
125
  }
126
+ const { failure } = settlement;
109
127
  if (failure.reason === 'http') {
110
128
  log(runtime).warn('recordSandboxUptime: non-2xx from account', { hostId: input.hostId, status: failure.status });
111
129
  }
@@ -117,6 +135,7 @@ export function recordSandboxUptime(runtime, input) {
117
135
  }
118
136
  const message = deliveryFailureMessage(failure, USAGE_RECORD_TIMEOUT_MS);
119
137
  await notifyJournal(log(runtime), 'recordSandboxUptime', () => input.journal?.onFailure?.({ reason: failure.reason, message }));
138
+ await notifyJournal(log(runtime), 'recordSandboxUptime', () => input.onOutcome?.({ delivery: 'failed', failure }));
120
139
  });
121
140
  }
122
141
  //# sourceMappingURL=record-sandbox-uptime.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"record-sandbox-uptime.js","sourceRoot":"","sources":["../../../src/billing/usage/record-sandbox-uptime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAmB,MAAM,qBAAqB,CAAC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AE,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAClH,CAAC;aAAM,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YACzC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,gCAAgC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC,CAAC;QACnH,CAAC;aAAM,CAAC;YACP,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,mCAAmC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QACxG,CAAC;QACD,MAAM,OAAO,GAAG,sBAAsB,CAAC,OAAO,EAAE,uBAAuB,CAAC,CAAC;QACzE,MAAM,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,qBAAqB,EAAE,GAAG,EAAE,CAC7D,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAC/D,CAAC;QACF,MAAM,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,qBAAqB,EAAE,GAAG,EAAE,CAC7D,KAAK,CAAC,SAAS,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAClD,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/cli/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAYH,eAAO,MAAM,gBAAgB,6CA+B3B,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/cli/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAaH,eAAO,MAAM,gBAAgB,6CAgC3B,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
@@ -16,6 +16,7 @@
16
16
  */
17
17
  import { createRuntimePlugin, loader } from '@vibesdotdev/kernel';
18
18
  import accountApiClientPlugin from '@vibesdotdev/account/api-client-plugin';
19
+ import accountOrgPlugin from "../org/account-org.plugin.js";
19
20
  import accountGroup from "./account-group.descriptor.js";
20
21
  import whoamiCommandDescriptor from "./commands/whoami.command.descriptor.js";
21
22
  import orgsCommandDescriptor from "./commands/orgs.command.descriptor.js";
@@ -47,6 +48,7 @@ export const accountCliPlugin = createRuntimePlugin({
47
48
  // impl resolves them via `getVibesClient`.
48
49
  onRegister: async (runtime) => {
49
50
  await runtime.registerPlugin(accountApiClientPlugin);
51
+ await runtime.registerPlugin(accountOrgPlugin);
50
52
  }
51
53
  });
52
54
  export default accountCliPlugin;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/cli/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,sBAAsB,MAAM,wCAAwC,CAAC;AAE5E,OAAO,YAAY,MAAM,+BAA+B,CAAC;AACzD,OAAO,uBAAuB,MAAM,yCAAyC,CAAC;AAC9E,OAAO,qBAAqB,MAAM,uCAAuC,CAAC;AAC1E,OAAO,uBAAuB,MAAM,0CAA0C,CAAC;AAE/E,MAAM,WAAW,GAAG,EAAE,IAAI,EAAE,aAAa,EAAW,CAAC;AAErD,MAAM,CAAC,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;IACnD,EAAE,EAAE,0BAA0B;IAC9B,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EACV,mGAAmG;IACpG,oEAAoE;IACpE,0EAA0E;IAC1E,wEAAwE;IACxE,yEAAyE;IACzE,iEAAiE;IACjE,YAAY,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EAAoE;IACpE,0EAA0E;IAC1E,wEAAwE;IACxE,yEAAyE;IACzE,iEAAiE;IACjE,YAAY,EAAE,CAAC,KAAK,CAAC;IAErB,WAAW,EAAE;QACZ,YAAY;QACZ,uBAAuB;QACvB,qBAAqB;QACrB,uBAAuB;KACvB;IAED,OAAO,EAAE;QACR,MAAM,CAAC,gBAAgB,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,mCAAmC,CAAC,CAAC;QACxF,MAAM,CAAC,cAAc,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,iCAAiC,CAAC,CAAC;QACpF,MAAM,CAAC,iBAAiB,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,oCAAoC,CAAC,CAAC;KAC1F;IAED,uEAAuE;IACvE,4EAA4E;IAC5E,2CAA2C;IAC3C,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QAC7B,MAAM,OAAO,CAAC,cAAc,CAAC,sBAAsB,CAAC,CAAC;QACrD,MAAM,OAAO,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC;IAChD,CAAC;CACD,CAAC,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
@@ -1,11 +1,10 @@
1
1
  /**
2
2
  * Account Org Plugin
3
3
  *
4
- * Registers request-scoped account context kinds (`orgId`, `userId`) with
5
- * the runtime. Apps populate the AsyncLocalStorage scope via
6
- * `runWithRequestContext(...)` in their hooks.server.ts; the runtime then
7
- * surfaces the values as `context.orgId` / `context.userId` in any
8
- * KindContext (notably `integration/provider`).
4
+ * Registers account context kinds (`orgId`, `userId`) with the runtime.
5
+ * Apps supply request values through `runWithRequestContext(...)`. The org
6
+ * context also uses the kernel invocation actor and, on an authenticated
7
+ * single-user interactive host, the user's stored organization selection.
9
8
  */
10
9
  export declare const accountOrgPlugin: import("@vibesdotdev/kernel").RuntimePlugin;
11
10
  export default accountOrgPlugin;
@@ -1 +1 @@
1
- {"version":3,"file":"account-org.plugin.d.ts","sourceRoot":"","sources":["../../src/org/account-org.plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,eAAO,MAAM,gBAAgB,6CAU3B,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"account-org.plugin.d.ts","sourceRoot":"","sources":["../../src/org/account-org.plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,eAAO,MAAM,gBAAgB,6CAU3B,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
@@ -1,11 +1,10 @@
1
1
  /**
2
2
  * Account Org Plugin
3
3
  *
4
- * Registers request-scoped account context kinds (`orgId`, `userId`) with
5
- * the runtime. Apps populate the AsyncLocalStorage scope via
6
- * `runWithRequestContext(...)` in their hooks.server.ts; the runtime then
7
- * surfaces the values as `context.orgId` / `context.userId` in any
8
- * KindContext (notably `integration/provider`).
4
+ * Registers account context kinds (`orgId`, `userId`) with the runtime.
5
+ * Apps supply request values through `runWithRequestContext(...)`. The org
6
+ * context also uses the kernel invocation actor and, on an authenticated
7
+ * single-user interactive host, the user's stored organization selection.
9
8
  */
10
9
  import { createRuntimePlugin } from '@vibesdotdev/kernel';
11
10
  import { loader } from '@vibesdotdev/kernel/factory';
@@ -14,7 +13,7 @@ import userIdContextDescriptor from "./userId.context.descriptor.js";
14
13
  export const accountOrgPlugin = createRuntimePlugin({
15
14
  id: 'account-org',
16
15
  name: 'Account Org Context',
17
- description: 'Request-scoped orgId and userId context kinds, backed by AsyncLocalStorage. Apps wrap their request lifecycle in `runWithRequestContext({ orgId, userId }, () => resolve(event))` to populate the scope.',
16
+ description: 'Account orgId and userId contexts for request scopes, invocation actors, and signed-in interactive hosts.',
18
17
  descriptors: [orgIdContextDescriptor, userIdContextDescriptor],
19
18
  loaders: [
20
19
  loader('orgId', { kind: 'context' }, () => import("./orgId.context.impl.js")),
@@ -1 +1 @@
1
- {"version":3,"file":"account-org.plugin.js","sourceRoot":"","sources":["../../src/org/account-org.plugin.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EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC;QAC7E,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC;KAC/E;CACD,CAAC,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
@@ -7,9 +7,8 @@
7
7
  * uniformly via `runtime.context('orgId')` or as `context.orgId` inside a
8
8
  * KindContext.
9
9
  *
10
- * Implementation is in `./orgId.context.impl.ts` and reads from the
11
- * AsyncLocalStorage scope established by `runWithRequestContext(...)` in
12
- * each app's hooks.server.ts.
10
+ * The implementation reads the Account request scope, then the kernel actor;
11
+ * a signed-in interactive host can use the organization selected by its user.
13
12
  */
14
13
  declare const _default: {
15
14
  id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"orgId.context.descriptor.d.ts","sourceRoot":"","sources":["../../src/org/orgId.context.descriptor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIH,wBAGG"}
1
+ {"version":3,"file":"orgId.context.descriptor.d.ts","sourceRoot":"","sources":["../../src/org/orgId.context.descriptor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIH,wBAGG"}
@@ -7,9 +7,8 @@
7
7
  * uniformly via `runtime.context('orgId')` or as `context.orgId` inside a
8
8
  * KindContext.
9
9
  *
10
- * Implementation is in `./orgId.context.impl.ts` and reads from the
11
- * AsyncLocalStorage scope established by `runWithRequestContext(...)` in
12
- * each app's hooks.server.ts.
10
+ * The implementation reads the Account request scope, then the kernel actor;
11
+ * a signed-in interactive host can use the organization selected by its user.
13
12
  */
14
13
  import { createContextDescriptor } from '@vibesdotdev/kernel/factory/context';
15
14
  export default createContextDescriptor({
@@ -1 +1 @@
1
- {"version":3,"file":"orgId.context.descriptor.js","sourceRoot":"","sources":["../../src/org/orgId.context.descriptor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAE9E,eAAe,uBAAuB,CAAC;IACtC,EAAE,EAAE,OAAO;IACX,WAAW,EAAE,uDAAuD;CACpE,CAAC,CAAC"}
1
+ {"version":3,"file":"orgId.context.descriptor.js","sourceRoot":"","sources":["../../src/org/orgId.context.descriptor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAE9E,eAAe,uBAAuB,CAAC;IACtC,EAAE,EAAE,OAAO;IACX,WAAW,EAAE,uDAAuD;CACpE,CAAC,CAAC"}
@@ -1,11 +1,10 @@
1
1
  /**
2
- * orgId Context Implementation
2
+ * Active organization for the current invocation.
3
3
  *
4
- * Returns the current request scope's `orgId` on the resolving runtime (or
5
- * undefined when no scope is active, e.g. CLI / worker / test boot, or the host
6
- * declares no request values). The runtime calls `provide(runtime)` each time
7
- * the context is resolved, so per-request changes are picked up automatically
8
- * without cache invalidation.
4
+ * A request's explicit Account scope wins, including its personal scope. A
5
+ * queued invocation carries its actor through the kernel. On a single-user
6
+ * interactive host, the signed-in account's stored selection supplies the
7
+ * organization when the invocation has not named one.
9
8
  */
10
9
  import type { RuntimeRef } from '@vibesdotdev/kernel';
11
10
  declare const _default: {
@@ -1 +1 @@
1
- {"version":3,"file":"orgId.context.impl.d.ts","sourceRoot":"","sources":["../../src/org/orgId.context.impl.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;;uBAIlC,UAAU,KAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;;AAD5D,wBAEE"}
1
+ {"version":3,"file":"orgId.context.impl.d.ts","sourceRoot":"","sources":["../../src/org/orgId.context.impl.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;;uBAW5B,UAAU,KAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;;AADlE,wBAsBE"}
@@ -1,14 +1,40 @@
1
1
  /**
2
- * orgId Context Implementation
2
+ * Active organization for the current invocation.
3
3
  *
4
- * Returns the current request scope's `orgId` on the resolving runtime (or
5
- * undefined when no scope is active, e.g. CLI / worker / test boot, or the host
6
- * declares no request values). The runtime calls `provide(runtime)` each time
7
- * the context is resolved, so per-request changes are picked up automatically
8
- * without cache invalidation.
4
+ * A request's explicit Account scope wins, including its personal scope. A
5
+ * queued invocation carries its actor through the kernel. On a single-user
6
+ * interactive host, the signed-in account's stored selection supplies the
7
+ * organization when the invocation has not named one.
9
8
  */
10
- import { getCurrentOrgId } from "./request-context.js";
9
+ import * as z from 'zod/v4';
10
+ import { loadConfigForScope } from '@vibesdotdev/config/services/config';
11
+ import { getCurrentRequestContext } from "./request-context.js";
12
+ const IdentitySchema = z.object({
13
+ isAuthenticated: z.literal(true),
14
+ userId: z.string().trim().min(1)
15
+ });
16
+ const OrganizationIdSchema = z.string().trim().min(1);
11
17
  export default {
12
- provide: (runtime) => getCurrentOrgId(runtime)
18
+ provide: async (runtime) => {
19
+ const request = await getCurrentRequestContext(runtime);
20
+ if (request)
21
+ return request.orgId;
22
+ const actor = runtime.scope.actor;
23
+ const capabilities = runtime.scope.capabilities;
24
+ const isInteractiveConsumer = Boolean(capabilities?.interactiveSession && !capabilities.sharedHost && !capabilities.requestPrincipals);
25
+ const isVerifiedConsumerActor = runtime.scope.hardware === 'consumer' && Boolean(actor?.userId);
26
+ if (!isInteractiveConsumer && !isVerifiedConsumerActor)
27
+ return actor?.orgId;
28
+ if (!runtime.hasContext('auth/identity'))
29
+ return actor?.orgId;
30
+ const identity = IdentitySchema.safeParse(await runtime.context('auth/identity'));
31
+ if (!identity.success || (actor?.userId && actor.userId !== identity.data.userId))
32
+ return undefined;
33
+ if (actor?.orgId)
34
+ return actor.orgId;
35
+ const config = await loadConfigForScope('global', runtime);
36
+ const organization = OrganizationIdSchema.safeParse(config.activeOrgId);
37
+ return organization.success ? organization.data : undefined;
38
+ }
13
39
  };
14
40
  //# sourceMappingURL=orgId.context.impl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"orgId.context.impl.js","sourceRoot":"","sources":["../../src/org/orgId.context.impl.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,eAAe;IACd,OAAO,EAAE,CAAC,OAAmB,EAA+B,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC;CACvF,CAAC"}
1
+ {"version":3,"file":"orgId.context.impl.js","sourceRoot":"","sources":["../../src/org/orgId.context.impl.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;IAChC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAChC,CAAC,CAAC;AACH,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAEtD,eAAe;IACd,OAAO,EAAE,KAAK,EAAE,OAAmB,EAA+B,EAAE;QACnE,MAAM,OAAO,GAAG,MAAM,wBAAwB,CAAC,OAAO,CAAC,CAAC;QACxD,IAAI,OAAO;YAAE,OAAO,OAAO,CAAC,KAAK,CAAC;QAElC,MAAM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olution reads.
4
+ * The manifest waits for `config/manifest` to be registered, so a host
5
+ * without the config plugin composes this without failing.
6
+ */
7
+ declare const defaultExport: import("@vibesdotdev/kernel").RuntimePlugin;
8
+ export default defaultExport;
9
+ //# sourceMappingURL=billing-overage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing-overage.d.ts","sourceRoot":"","sources":["../../src/plugin/billing-overage.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AAEH,QAAA,MAAM,aAAa,6CAKjB,CAAC;AAEH,eAAe,aAAa,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { createRuntimePlugin } from '@vibesdotdev/kernel';
2
+ import overagePolicyManifest from "../billing/overage/overage-policy.config.descriptor.js";
3
+ /**
4
+ * Billing overage policy subplugin — registers the `billing.overage`
5
+ * config/manifest, the declared defaults every overage resolution reads.
6
+ * The manifest waits for `config/manifest` to be registered, so a host
7
+ * without the config plugin composes this without failing.
8
+ */
9
+ // Hoisted const: tsc rewriteRelativeImportExtensions does not rewrite `.ts` specifiers inside `export default <expr>` (TS 6.0.3).
10
+ const defaultExport = createRuntimePlugin({
11
+ id: 'account-billing-overage',
12
+ name: 'Account Billing Overage Policy',
13
+ description: 'Declares the billing.overage policy defaults.',
14
+ descriptors: [overagePolicyManifest]
15
+ });
16
+ export default defaultExport;
17
+ //# sourceMappingURL=billing-overage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing-overage.js","sourceRoot":"","sources":["../../src/plugin/billing-overage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,qBAAqB,MAAM,wDAAwD,CAAC;AAE3F;;;;;GAKG;AACH,kIAAkI;AAClI,MAAM,aAAa,GAAG,mBAAmB,CAAC;IACzC,EAAE,EAAE,yBAAyB;IAC7B,IAAI,EAAE,gCAAgC;IACtC,WAAW,EAAE,+CAA+C;IAC5D,WAAW,EAAE,CAAC,qBAAqB,CAAC;CACpC,CAAC,CAAC;AAEH,eAAe,aAAa,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,cAAc,+CAO1B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,cAAc,+CAS1B,CAAC"}
@@ -2,14 +2,18 @@ import accountSupportPlugin from "./support.js";
2
2
  import accountClientPlugin from "./client.js";
3
3
  import accountApiClientPlugin from "./api-client.js";
4
4
  import accountBillingHooksPlugin from "./billing-hooks.js";
5
+ import accountBillingOveragePlugin from "./billing-overage.js";
5
6
  import accountWorkersUsagePlugin from "./workers-usage.js";
6
7
  import accountSettingsStoragePlugin from "./settings-storage.js";
8
+ import accountOrgPlugin from "../org/account-org.plugin.js";
7
9
  export const accountPlugins = [
8
10
  accountSupportPlugin,
9
11
  accountClientPlugin,
10
12
  accountApiClientPlugin,
11
13
  accountBillingHooksPlugin,
14
+ accountBillingOveragePlugin,
12
15
  accountWorkersUsagePlugin,
13
- accountSettingsStoragePlugin
16
+ accountSettingsStoragePlugin,
17
+ accountOrgPlugin
14
18
  ];
15
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,cAAc,CAAC;AAChD,OAAO,mBAAmB,MAAM,aAAa,CAAC;AAC9C,OAAO,sBAAsB,MAAM,iBAAiB,CAAC;AACrD,OAAO,yBAAyB,MAAM,oBAAoB,CAAC;AAC3D,OAAO,yBAAyB,MAAM,oBAAoB,CAAC;AAC3D,OAAO,4BAA4B,MAAM,uBAAuB,CAAC;AAEjE,MAAM,CAAC,MAAM,cAAc,GAAG;IAC7B,oBAAoB;IACpB,mBAAmB;IACnB,sBAAsB;IACtB,yBAAyB;IACzB,yBAAyB;IACzB,4BAA4B;CAC5B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,cAAc,CAAC;AAChD,OAAO,mBAAmB,MAAM,aAAa,CAAC;AAC9C,OAAO,sBAAsB,MAAM,iBAAiB,CAAC;AACrD,OAAO,yBAAyB,MAAM,oBAAoB,CAAC;AAC3D,OAAO,2BAA2B,MAAM,sBAAsB,CAAC;AAC/D,OAAO,yBAAyB,MAAM,oBAAoB,CAAC;AAC3D,OAAO,4BAA4B,MAAM,uBAAuB,CAAC;AACjE,OAAO,gBAAgB,MAAM,8BAA8B,CAAC;AAE5D,MAAM,CAAC,MAAM,cAAc,GAAG;IAC7B,oBAAoB;IACpB,mBAAmB;IACnB,sBAAsB;IACtB,yBAAyB;IACzB,2BAA2B;IAC3B,yBAAyB;IACzB,4BAA4B;IAC5B,gBAAgB;CAChB,CAAC"}
@@ -1,11 +1,20 @@
1
1
  import * as z from 'zod/v4';
2
+ /**
3
+ * The base case: a host that composes this plugin reads the canonical
4
+ * internal-service secret without also having to declare the reference in its
5
+ * workspace composition. A host that stores a different reference overrides it.
6
+ */
7
+ export declare const CANONICAL_ACCOUNT_SYSTEM_ADMIN_CREDENTIAL: Readonly<{
8
+ source: "secret";
9
+ key: "VIBES_INTERNAL_SERVICE_TOKEN";
10
+ }>;
2
11
  export declare const AccountSystemConfigSchema: z.ZodObject<{
3
- adminCredential: z.ZodDiscriminatedUnion<[z.ZodObject<{
12
+ adminCredential: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{
4
13
  source: z.ZodLiteral<"secret">;
5
14
  key: z.ZodString;
6
15
  store: z.ZodOptional<z.ZodString>;
7
16
  operation: z.ZodOptional<z.ZodCustom<object, object>>;
8
- }, z.core.$strict>], "source">;
17
+ }, z.core.$strict>], "source">>;
9
18
  }, z.core.$strict>;
10
19
  export type AccountSystemConfig = z.infer<typeof AccountSystemConfigSchema>;
11
20
  declare const _default: {
@@ -14,12 +23,12 @@ declare const _default: {
14
23
  name: string;
15
24
  namespace: string;
16
25
  schema: z.ZodObject<{
17
- adminCredential: z.ZodDiscriminatedUnion<[z.ZodObject<{
26
+ adminCredential: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{
18
27
  source: z.ZodLiteral<"secret">;
19
28
  key: z.ZodString;
20
29
  store: z.ZodOptional<z.ZodString>;
21
30
  operation: z.ZodOptional<z.ZodCustom<object, object>>;
22
- }, z.core.$strict>], "source">;
31
+ }, z.core.$strict>], "source">>;
23
32
  }, z.core.$strict>;
24
33
  scope: "global";
25
34
  tier: "system";
@@ -29,6 +38,10 @@ declare const _default: {
29
38
  customTables: false;
30
39
  version: number;
31
40
  internal: true;
41
+ credentials: {
42
+ field: string;
43
+ purpose: string;
44
+ }[];
32
45
  };
33
46
  export default _default;
34
47
  //# sourceMappingURL=account-system.config.descriptor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"account-system.config.descriptor.d.ts","sourceRoot":"","sources":["../../src/system/account-system.config.descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAI5B,eAAO,MAAM,yBAAyB;;;;;;;kBAAiE,CAAC;AACxG,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;AAC5E,wBAMqC"}
1
+ {"version":3,"file":"account-system.config.descriptor.d.ts","sourceRoot":"","sources":["../../src/system/account-system.config.descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAI5B;;;;GAIG;AACH,eAAO,MAAM,yCAAyC;;;EAGpD,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;kBAEpC,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;AAC5E,wBAOqC"}
@@ -1,11 +1,23 @@
1
1
  import * as z from 'zod/v4';
2
2
  import { CredentialReferenceSchema } from '@vibesdotdev/kernel/credentials';
3
- export const AccountSystemConfigSchema = z.strictObject({ adminCredential: CredentialReferenceSchema });
3
+ /**
4
+ * The base case: a host that composes this plugin reads the canonical
5
+ * internal-service secret without also having to declare the reference in its
6
+ * workspace composition. A host that stores a different reference overrides it.
7
+ */
8
+ export const CANONICAL_ACCOUNT_SYSTEM_ADMIN_CREDENTIAL = Object.freeze({
9
+ source: 'secret',
10
+ key: 'VIBES_INTERNAL_SERVICE_TOKEN'
11
+ });
12
+ export const AccountSystemConfigSchema = z.strictObject({
13
+ adminCredential: CredentialReferenceSchema.default(CANONICAL_ACCOUNT_SYSTEM_ADMIN_CREDENTIAL)
14
+ });
4
15
  export default {
5
16
  id: 'account.system', kind: 'config/manifest', name: 'Account administration',
6
17
  namespace: 'account.system', schema: AccountSystemConfigSchema,
7
18
  scope: 'global', tier: 'system', storedLayer: 'none',
8
19
  allowedAdapters: ['storage.json', 'storage.localdb'], fields: {},
9
- customTables: false, version: 1, internal: true
20
+ customTables: false, version: 1, internal: true,
21
+ credentials: [{ field: 'adminCredential', purpose: 'Authenticates system administration calls to the account admin API.' }]
10
22
  };
11
23
  //# sourceMappingURL=account-system.config.descriptor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"account-system.config.descriptor.js","sourceRoot":"","sources":["../../src/system/account-system.config.descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAG5E,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,YAAY,CAAC,EAAE,eAAe,EAAE,yBAAyB,EAAE,CAAC,CAAC;AAExG,eAAe;IACd,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,iBAAiB,EAAE,IA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AE,CAAC;CACxF,CAAC"}
@@ -1,5 +1,10 @@
1
- import type { RuntimeRef } from '@vibesdotdev/kernel';
1
+ import { type RuntimeRef } from '@vibesdotdev/kernel';
2
2
  export declare function resolveAccountSystemOrigin(runtime: RuntimeRef): Promise<string>;
3
- /** The host declares one reference; missing credentials and store failures stay typed. */
3
+ /**
4
+ * The host declares one reference; missing credentials and store failures stay typed.
5
+ * Account exposes no kernel kind for this credential, so the caller reaches it by
6
+ * this function: a host that does not compose the `account.system` plugin is
7
+ * refused with a composition error naming the plugin and key, not a lookup miss.
8
+ */
4
9
  export declare function resolveAccountSystemAdminToken(runtime: RuntimeRef): Promise<string>;
5
10
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/system/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAKtD,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAE/E;AAED,0FAA0F;AAC1F,wBAAsB,8BAA8B,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAKzF"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/system/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAKvE,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAE/E;AAED;;;;;GAKG;AACH,wBAAsB,8BAA8B,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAiBzF"}
@@ -1,10 +1,24 @@
1
+ import { CapabilityError } from '@vibesdotdev/kernel';
1
2
  import { ConfigManifest } from '@vibesdotdev/config/manifest/config-manifest';
2
3
  import { serviceOrigin } from '@vibesdotdev/infra-core/service';
3
4
  export function resolveAccountSystemOrigin(runtime) {
4
5
  return serviceOrigin(runtime, 'account', 'internal');
5
6
  }
6
- /** The host declares one reference; missing credentials and store failures stay typed. */
7
+ /**
8
+ * The host declares one reference; missing credentials and store failures stay typed.
9
+ * Account exposes no kernel kind for this credential, so the caller reaches it by
10
+ * this function: a host that does not compose the `account.system` plugin is
11
+ * refused with a composition error naming the plugin and key, not a lookup miss.
12
+ */
7
13
  export async function resolveAccountSystemAdminToken(runtime) {
14
+ if (!ConfigManifest.isRegistered(runtime, 'account.system')) {
15
+ throw new CapabilityError("This host reads the account administration credential but does not compose the 'account.system' plugin.", 'UNAVAILABLE', {
16
+ reason: 'account-system-not-composed',
17
+ retryable: false,
18
+ details: { plugin: 'account.system', manifest: 'account.system', key: 'adminCredential' },
19
+ recoveryHint: "Select '@vibesdotdev/account/system/plugin' in this host's composition and set config['account.system'].adminCredential."
20
+ });
21
+ }
8
22
  const config = await ConfigManifest.forRuntime(runtime, 'account.system').load();
9
23
  const result = await runtime.resolveCredential(config.adminCredential);
10
24
  if (!result.ok)
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/system/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAGhE,MAAM,UAAU,0BAA0B,CAAC,OAAmB;IAC7D,OAAO,aAAa,CAAC,OAAO,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AACtD,CAAC;AAED,0FAA0F;AAC1F,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAAC,OAAmB;IACvE,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,UAAU,CAAsB,OAAO,EAAE,gBAAgB,CAAC,CAAC,IAAI,EAAE,CAAC;IACtG,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IACvE,IAAI,CAAC,MAA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