@ottimis/jack-provider-sdk 0.9.0 → 0.13.0

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.
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ /**
3
+ * Provider-declared user defaults — per-provider "what you want this provider
4
+ * to pick when a new session is created".
5
+ *
6
+ * Three field kinds are supported today: `model`, `effort`, and
7
+ * `permission_mode`. Each provider declares which of those are meaningful
8
+ * for its runtime and the catalog of legal values for each. The host owns
9
+ * storage (via `HostServices.kv`) and resolution (`resolveProviderDefaults`
10
+ * merges global → workspace → agent layers in the future; v1 is global
11
+ * only). The provider only declares the **catalog**; it never persists or
12
+ * resolves values itself.
13
+ *
14
+ * Design notes
15
+ * ------------
16
+ * - Catalog-only contract. The provider is authoritative on "what's
17
+ * settable" and "with which values". The host validates writes against
18
+ * this catalog and silently ignores stored values that fall outside it
19
+ * (e.g. after a provider bump removed a model).
20
+ * - Presence-based gating. A provider that doesn't declare `defaults`
21
+ * simply doesn't appear in `Settings → Provider defaults` and no
22
+ * pre-fill happens. No `CapabilityMatrix` flag needed.
23
+ * - Open for layering. The resolver signature (`workspaceId?`,
24
+ * `agentSlotId?`) is in v1 even though only the global layer is
25
+ * implemented, so adding workspace/agent overrides later is a host-only
26
+ * change without touching the SDK.
27
+ *
28
+ * Cross-references in the existing SDK surface
29
+ * --------------------------------------------
30
+ * - `model` overlaps with `JackProvider.modelOptions` (live dropdown) and
31
+ * `ProviderModelDefaults.oneShot` (host suggester tasks). The
32
+ * `ProviderDefaultsApi` is distinct: it answers "what model do new
33
+ * sessions get". A provider typically reuses `modelOptions` as the
34
+ * defaults catalog but it's not required (e.g. a provider could hide
35
+ * experimental models from the default-picker while keeping them in
36
+ * the live switcher).
37
+ * - `effort` mirrors `JackProvider.effortLevels` semantics. Codex applies
38
+ * effort at spawn time; declaring it as a default is how the host
39
+ * honours that without an extra dropdown in `NewSessionDialog`.
40
+ * - `permission_mode` mirrors `CapabilityMatrix.permissionModes`. The
41
+ * default is the mode every freshly-created session starts in
42
+ * (the user can still cycle it live via Shift-Tab if
43
+ * `livePermissionModeSwitch` is true).
44
+ */
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/defaults.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG"}
package/dist/cjs/index.js CHANGED
@@ -49,4 +49,6 @@ __exportStar(require("./usage"), exports);
49
49
  __exportStar(require("./host"), exports);
50
50
  __exportStar(require("./profiles"), exports);
51
51
  __exportStar(require("./sandbox"), exports);
52
+ __exportStar(require("./oneshot"), exports);
53
+ __exportStar(require("./defaults"), exports);
52
54
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;;;;;;;;;;;;;;AAEH,4CAAyB;AACzB,4CAAyB;AACzB,6CAA0B;AAC1B,0CAAuB;AACvB,yCAAsB;AACtB,6CAA0B;AAC1B,4CAAyB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;;;;;;;;;;;;;;AAEH,4CAAyB;AACzB,4CAAyB;AACzB,6CAA0B;AAC1B,0CAAuB;AACvB,yCAAsB;AACtB,6CAA0B;AAC1B,4CAAyB;AACzB,4CAAyB;AACzB,6CAA0B"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=oneshot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oneshot.js","sourceRoot":"","sources":["../../src/oneshot.ts"],"names":[],"mappings":""}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Provider-declared user defaults — per-provider "what you want this provider
3
+ * to pick when a new session is created".
4
+ *
5
+ * Three field kinds are supported today: `model`, `effort`, and
6
+ * `permission_mode`. Each provider declares which of those are meaningful
7
+ * for its runtime and the catalog of legal values for each. The host owns
8
+ * storage (via `HostServices.kv`) and resolution (`resolveProviderDefaults`
9
+ * merges global → workspace → agent layers in the future; v1 is global
10
+ * only). The provider only declares the **catalog**; it never persists or
11
+ * resolves values itself.
12
+ *
13
+ * Design notes
14
+ * ------------
15
+ * - Catalog-only contract. The provider is authoritative on "what's
16
+ * settable" and "with which values". The host validates writes against
17
+ * this catalog and silently ignores stored values that fall outside it
18
+ * (e.g. after a provider bump removed a model).
19
+ * - Presence-based gating. A provider that doesn't declare `defaults`
20
+ * simply doesn't appear in `Settings → Provider defaults` and no
21
+ * pre-fill happens. No `CapabilityMatrix` flag needed.
22
+ * - Open for layering. The resolver signature (`workspaceId?`,
23
+ * `agentSlotId?`) is in v1 even though only the global layer is
24
+ * implemented, so adding workspace/agent overrides later is a host-only
25
+ * change without touching the SDK.
26
+ *
27
+ * Cross-references in the existing SDK surface
28
+ * --------------------------------------------
29
+ * - `model` overlaps with `JackProvider.modelOptions` (live dropdown) and
30
+ * `ProviderModelDefaults.oneShot` (host suggester tasks). The
31
+ * `ProviderDefaultsApi` is distinct: it answers "what model do new
32
+ * sessions get". A provider typically reuses `modelOptions` as the
33
+ * defaults catalog but it's not required (e.g. a provider could hide
34
+ * experimental models from the default-picker while keeping them in
35
+ * the live switcher).
36
+ * - `effort` mirrors `JackProvider.effortLevels` semantics. Codex applies
37
+ * effort at spawn time; declaring it as a default is how the host
38
+ * honours that without an extra dropdown in `NewSessionDialog`.
39
+ * - `permission_mode` mirrors `CapabilityMatrix.permissionModes`. The
40
+ * default is the mode every freshly-created session starts in
41
+ * (the user can still cycle it live via Shift-Tab if
42
+ * `livePermissionModeSwitch` is true).
43
+ */
44
+ import type { AgentEffortLevel, AgentPermissionMode } from './backend';
45
+ /**
46
+ * One field a provider exposes in the defaults form. Discriminated union
47
+ * keyed on `kind` so the host renders the right widget (string-id select
48
+ * for model, enum select for effort, etc.) without provider-specific code.
49
+ *
50
+ * `options` is the catalog of legal values. Empty → host hides the field
51
+ * (parity with `JackProvider.modelOptions` / `effortLevels` semantics).
52
+ */
53
+ export type ProviderDefaultsField = {
54
+ kind: 'model';
55
+ /**
56
+ * Catalog of model identifiers. `value` is what the host writes into
57
+ * `sessions.model` at create time; `label` is the human display.
58
+ * Typically reuses `JackProvider.modelOptions` 1:1 but providers MAY
59
+ * filter (e.g. hide experimental models from new-session pre-fill).
60
+ */
61
+ options: ReadonlyArray<{
62
+ value: string;
63
+ label: string;
64
+ }>;
65
+ } | {
66
+ kind: 'effort';
67
+ /**
68
+ * Catalog of effort tiers. `value` MUST be a member of
69
+ * {@link AgentEffortLevel}. Renderer falls back to the raw string as
70
+ * the label.
71
+ */
72
+ options: ReadonlyArray<AgentEffortLevel>;
73
+ } | {
74
+ kind: 'permission_mode';
75
+ /**
76
+ * Catalog of permission modes available as session-start defaults.
77
+ * Typically equals `CapabilityMatrix.permissionModes` but providers
78
+ * MAY narrow (e.g. exclude `'bypassPermissions'` from the default
79
+ * picker even when the cycle supports it — the user has to opt in
80
+ * deliberately).
81
+ */
82
+ options: ReadonlyArray<AgentPermissionMode>;
83
+ };
84
+ /**
85
+ * Provider-declared catalog of configurable defaults. Static — the host
86
+ * reads `fields` once per provider listing and validates user writes
87
+ * against it. Empty array would technically be valid but pointless; the
88
+ * convention is "omit `JackProvider.defaults` entirely" for providers
89
+ * with no defaults to expose.
90
+ */
91
+ export type ProviderDefaultsApi = {
92
+ readonly fields: ReadonlyArray<ProviderDefaultsField>;
93
+ };
94
+ /**
95
+ * Resolved defaults as the host serialises them per-provider in kv. Every
96
+ * field is optional — "not set" means "use the provider's runtime default"
97
+ * (model NULL, effort NULL, permission_mode 'default').
98
+ *
99
+ * Stored as a single JSON blob at `provider.<id>.defaults` so partial
100
+ * writes are atomic and the host can wipe the whole bag in one call.
101
+ */
102
+ export type ProviderDefaultsValues = {
103
+ model?: string;
104
+ effort?: AgentEffortLevel;
105
+ permissionMode?: AgentPermissionMode;
106
+ };
107
+ /**
108
+ * Context the host resolver consumes. v1 only honours `providerId` (global
109
+ * defaults). `workspaceId` and `agentSlotId` are reserved placeholders for
110
+ * future per-workspace and per-agent overrides — the resolver signature
111
+ * accepts them today so the call sites can be written once and the host
112
+ * gains layering later without a callsite change.
113
+ *
114
+ * Resolution order (when layering lands): agent slot > workspace > global.
115
+ * Per-field merge: each field is resolved independently, so an agent slot
116
+ * can override `model` while letting `permissionMode` fall through to the
117
+ * global value.
118
+ */
119
+ export type ProviderDefaultsResolveContext = {
120
+ providerId: string;
121
+ /** Reserved for future per-workspace defaults; ignored in v1. */
122
+ workspaceId?: string;
123
+ /** Reserved for future per-agent-slot defaults; ignored in v1. */
124
+ agentSlotId?: string;
125
+ };
126
+ //# sourceMappingURL=defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAEtE;;;;;;;GAOG;AACH,MAAM,MAAM,qBAAqB,GAC7B;IACE,IAAI,EAAE,OAAO,CAAA;IACb;;;;;OAKG;IACH,OAAO,EAAE,aAAa,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACzD,GACD;IACE,IAAI,EAAE,QAAQ,CAAA;IACd;;;;OAIG;IACH,OAAO,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAA;CACzC,GACD;IACE,IAAI,EAAE,iBAAiB,CAAA;IACvB;;;;;;OAMG;IACH,OAAO,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAA;CAC5C,CAAA;AAEL;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAA;CACtD,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,gBAAgB,CAAA;IACzB,cAAc,CAAC,EAAE,mBAAmB,CAAA;CACrC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,UAAU,EAAE,MAAM,CAAA;IAClB,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kEAAkE;IAClE,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Provider-declared user defaults — per-provider "what you want this provider
3
+ * to pick when a new session is created".
4
+ *
5
+ * Three field kinds are supported today: `model`, `effort`, and
6
+ * `permission_mode`. Each provider declares which of those are meaningful
7
+ * for its runtime and the catalog of legal values for each. The host owns
8
+ * storage (via `HostServices.kv`) and resolution (`resolveProviderDefaults`
9
+ * merges global → workspace → agent layers in the future; v1 is global
10
+ * only). The provider only declares the **catalog**; it never persists or
11
+ * resolves values itself.
12
+ *
13
+ * Design notes
14
+ * ------------
15
+ * - Catalog-only contract. The provider is authoritative on "what's
16
+ * settable" and "with which values". The host validates writes against
17
+ * this catalog and silently ignores stored values that fall outside it
18
+ * (e.g. after a provider bump removed a model).
19
+ * - Presence-based gating. A provider that doesn't declare `defaults`
20
+ * simply doesn't appear in `Settings → Provider defaults` and no
21
+ * pre-fill happens. No `CapabilityMatrix` flag needed.
22
+ * - Open for layering. The resolver signature (`workspaceId?`,
23
+ * `agentSlotId?`) is in v1 even though only the global layer is
24
+ * implemented, so adding workspace/agent overrides later is a host-only
25
+ * change without touching the SDK.
26
+ *
27
+ * Cross-references in the existing SDK surface
28
+ * --------------------------------------------
29
+ * - `model` overlaps with `JackProvider.modelOptions` (live dropdown) and
30
+ * `ProviderModelDefaults.oneShot` (host suggester tasks). The
31
+ * `ProviderDefaultsApi` is distinct: it answers "what model do new
32
+ * sessions get". A provider typically reuses `modelOptions` as the
33
+ * defaults catalog but it's not required (e.g. a provider could hide
34
+ * experimental models from the default-picker while keeping them in
35
+ * the live switcher).
36
+ * - `effort` mirrors `JackProvider.effortLevels` semantics. Codex applies
37
+ * effort at spawn time; declaring it as a default is how the host
38
+ * honours that without an extra dropdown in `NewSessionDialog`.
39
+ * - `permission_mode` mirrors `CapabilityMatrix.permissionModes`. The
40
+ * default is the mode every freshly-created session starts in
41
+ * (the user can still cycle it live via Shift-Tab if
42
+ * `livePermissionModeSwitch` is true).
43
+ */
44
+ export {};
45
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG"}
package/dist/host.d.ts CHANGED
@@ -157,5 +157,22 @@ export type HostServices = {
157
157
  kv: HostKvScope;
158
158
  /** Auth flow primitives (cookie login today; OAuth / device-code in the future). */
159
159
  auth: HostAuthService;
160
+ /**
161
+ * Number of sessions currently pinned to a given profile id. Used by
162
+ * providers that surface profiles (`JackProvider.profiles`) to gate
163
+ * destructive operations:
164
+ *
165
+ * - `remove(profileId)` refuses when count > 0 so the user can't
166
+ * orphan the chat history of any pinned session.
167
+ * - `update(profileId, { configDir })` may surface a confirm dialog
168
+ * when count > 0 (UI-side concern; the API itself stays open since
169
+ * the user can move the on-disk `projects/`/rollouts folder
170
+ * manually to preserve history).
171
+ *
172
+ * Optional: providers without a profile concept never call it. The
173
+ * host implementation reads `SELECT COUNT(*) FROM sessions WHERE
174
+ * profile_id = ?`.
175
+ */
176
+ profileUsageCount?(profileId: string): number;
160
177
  };
161
178
  //# sourceMappingURL=host.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,gCAAgC;IAChC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAC/B,iCAAiC;IACjC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACrC,4EAA4E;IAC5E,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,iIAAiI;IACjI,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IACrC,oJAAoJ;IACpJ,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5C,CAAA;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAA;IACX,uEAAuE;IACvE,UAAU,EAAE,MAAM,CAAA;IAClB,sEAAsE;IACtE,YAAY,EAAE,MAAM,CAAA;IACpB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACxC;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAEpC;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;;;;;;OASG;IACH,qBAAqB,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;CAC5E,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,2EAA2E;IAC3E,EAAE,EAAE,WAAW,CAAA;IACf,oFAAoF;IACpF,IAAI,EAAE,eAAe,CAAA;CACtB,CAAA"}
1
+ {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,gCAAgC;IAChC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAC/B,iCAAiC;IACjC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACrC,4EAA4E;IAC5E,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,iIAAiI;IACjI,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IACrC,oJAAoJ;IACpJ,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5C,CAAA;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAA;IACX,uEAAuE;IACvE,UAAU,EAAE,MAAM,CAAA;IAClB,sEAAsE;IACtE,YAAY,EAAE,MAAM,CAAA;IACpB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACxC;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAEpC;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;;;;;;OASG;IACH,qBAAqB,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;CAC5E,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,2EAA2E;IAC3E,EAAE,EAAE,WAAW,CAAA;IACf,oFAAoF;IACpF,IAAI,EAAE,eAAe,CAAA;IACrB;;;;;;;;;;;;;;;OAeG;IACH,iBAAiB,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAA;CAC9C,CAAA"}
package/dist/index.d.ts CHANGED
@@ -33,6 +33,8 @@ export * from './usage';
33
33
  export * from './host';
34
34
  export * from './profiles';
35
35
  export * from './sandbox';
36
+ export * from './oneshot';
37
+ export * from './defaults';
36
38
  /**
37
39
  * Re-export of `NormalizedMessage` from chat-core so consumers don't need
38
40
  * to depend on it directly when their only entrypoint into the wire shape
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AAEzB;;;;;GAKG;AACH,YAAY,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAE1B;;;;;GAKG;AACH,YAAY,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA"}
package/dist/index.js CHANGED
@@ -33,4 +33,6 @@ export * from './usage';
33
33
  export * from './host';
34
34
  export * from './profiles';
35
35
  export * from './sandbox';
36
+ export * from './oneshot';
37
+ export * from './defaults';
36
38
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * One-shot completion capability — fire-and-forget AI calls outside the
3
+ * lifetime of a session.
4
+ *
5
+ * Use cases the host wires this for:
6
+ * - Auto-generate a commit message from a staged diff (CommitComposer).
7
+ * - Future: summarize a tool result, propose a search query, name a
8
+ * workspace from its first prompt, etc.
9
+ *
10
+ * Distinct from {@link AgentBackend.query} on purpose:
11
+ * - No tools, no MCP, no permission flow, no resume.
12
+ * - No persisted session — the provider MUST NOT leave artifacts on disk.
13
+ * - Returns plain text, synchronously to the caller (no streaming UI).
14
+ * - Reuses whatever auth/credentials the user already has (CLI cookie,
15
+ * API key, OAuth token) — same source as session calls.
16
+ *
17
+ * Provider implementations are expected to be **cheap and fast**: pick the
18
+ * smallest reasonable model the user is authenticated for, no agentic
19
+ * loops, no tool definitions, no caching beyond what the platform does on
20
+ * its own. A typical call should complete in well under a second.
21
+ */
22
+ export type OneshotCompleteOptions = {
23
+ /**
24
+ * The user prompt — what the model should respond to. The host builds
25
+ * this string by interpolating the relevant context (diff, branch,
26
+ * recent commit subjects, …) into a stable template; providers MUST
27
+ * NOT re-prompt or transform it beyond what's needed for their wire
28
+ * format.
29
+ */
30
+ prompt: string;
31
+ /**
32
+ * Optional system prompt. Use sparingly — keeping the host-side prompt
33
+ * provider-neutral means we can fan out the same call across providers
34
+ * without re-tuning. Implementations that don't have a system slot
35
+ * (rare) MAY prepend this to `prompt` and document the choice.
36
+ */
37
+ system?: string;
38
+ /**
39
+ * Cap on output tokens. Providers MUST honor it as best they can; the
40
+ * host treats overruns as warnings, not errors. Defaults are
41
+ * provider-specific.
42
+ */
43
+ maxOutputTokens?: number;
44
+ /**
45
+ * Cap on wall-clock time. Providers SHOULD abort the underlying request
46
+ * when the deadline is exceeded and reject the returned promise rather
47
+ * than block the caller forever. Default is provider-specific.
48
+ */
49
+ timeoutMs?: number;
50
+ /**
51
+ * AbortSignal — host-controlled cancellation. Providers MUST wire this
52
+ * into their underlying HTTP / process call so the renderer can drop a
53
+ * pending generation when the user closes the dialog or navigates away.
54
+ */
55
+ signal?: AbortSignal;
56
+ };
57
+ /**
58
+ * One-shot completion API — optional capability on {@link JackProvider}.
59
+ *
60
+ * Providers that expose this MUST also declare `capabilities.oneshot =
61
+ * true`. The host uses the capability flag to gate UI affordances (button
62
+ * disabled, tooltip explaining "active provider doesn't support this")
63
+ * before ever calling into the provider, so the API surface stays simple:
64
+ * providers don't need to throw a "not implemented" error — they just
65
+ * leave the field undefined.
66
+ */
67
+ export type OneshotApi = {
68
+ /**
69
+ * Run a single non-agentic completion and return the assistant's text
70
+ * verbatim — no streaming, no tool calls, no follow-up turns.
71
+ *
72
+ * Errors:
73
+ * - Network / auth: reject with the underlying error. Host catches and
74
+ * surfaces a toast.
75
+ * - AbortSignal aborted: reject with `DOMException('AbortError')`.
76
+ * - Empty / malformed model output: return an empty string. Host
77
+ * treats empty as "no suggestion" and keeps the textarea unchanged.
78
+ */
79
+ complete(opts: OneshotCompleteOptions): Promise<string>;
80
+ };
81
+ //# sourceMappingURL=oneshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oneshot.d.ts","sourceRoot":"","sources":["../src/oneshot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;OAIG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB,CAAA;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;CACxD,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=oneshot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oneshot.js","sourceRoot":"","sources":["../src/oneshot.ts"],"names":[],"mappings":""}
@@ -16,7 +16,9 @@
16
16
  * it free of provider-specific imports.
17
17
  */
18
18
  import type { AgentBackend, AgentPermissionMode, AgentQueryOptions, McpServerSpec } from './backend';
19
+ import type { ProviderDefaultsApi } from './defaults';
19
20
  import type { HostServices } from './host';
21
+ import type { OneshotApi } from './oneshot';
20
22
  import type { ProfilesApi } from './profiles';
21
23
  import type { SandboxApi } from './sandbox';
22
24
  import type { UsageApi } from './usage';
@@ -29,7 +31,7 @@ export type ProviderId = string;
29
31
  * commands carry `body` + `filePath`, builtin and wire-sourced ones
30
32
  * don't (they don't *have* a markdown file behind them).
31
33
  */
32
- export type SlashCommandScope = 'builtin' | 'wire' | 'user' | 'project' | (string & {});
34
+ export type SlashCommandScope = 'builtin' | 'wire' | 'user' | 'project' | 'jack-builtin' | (string & {});
33
35
  /**
34
36
  * Common surface every slash command def carries regardless of source.
35
37
  * The renderer uses these for autocomplete + chip rendering.
@@ -40,7 +42,7 @@ type SlashCommandDefBase = {
40
42
  argumentHint?: string;
41
43
  };
42
44
  /**
43
- * Slash-command definition surfaced by a provider. Three sources can
45
+ * Slash-command definition surfaced by a provider. Four sources can
44
46
  * coexist (see {@link SlashCommandSupport}):
45
47
  *
46
48
  * - `'builtin'` — static catalog the runtime intercepts. The renderer
@@ -53,6 +55,14 @@ type SlashCommandDefBase = {
53
55
  * `filePath` + `body` are required so the renderer can offer "open
54
56
  * in editor" affordances and the host can expand `$ARGUMENTS` /
55
57
  * `$N` placeholders.
58
+ * - `'jack-builtin'` — host-shipped slash command pack distributed
59
+ * inside the Jack app bundle (e.g. `/changelog-turn`,
60
+ * `/save-decision` for the user-data-tables feature). Read-only
61
+ * for the user (no edit/delete), expanded the same way as
62
+ * `'user'/'project'` (`$ARGUMENTS` + `$N` substitution). The body
63
+ * comes from `resources/slash-commands/builtin/<name>.md`; the
64
+ * renderer treats the catalog like any file-sourced command but
65
+ * hides authoring affordances behind the `readonly` flag.
56
66
  *
57
67
  * Discriminated by `scope` so consumers narrow before reading the
58
68
  * file-only fields. Replaces the legacy uniform shape that forced
@@ -67,7 +77,34 @@ export type SlashCommandDef = (SlashCommandDefBase & {
67
77
  scope: 'user' | 'project';
68
78
  body: string;
69
79
  filePath: string;
80
+ }) | (SlashCommandDefBase & {
81
+ scope: 'jack-builtin';
82
+ body: string;
83
+ readonly: true;
70
84
  });
85
+ /**
86
+ * Input shape for {@link SlashCommandSupport.createCommand}. The host
87
+ * collects these fields from a dialog form and hands them verbatim to
88
+ * the provider, which writes the markdown file in its native layout
89
+ * (Claude: `~/.claude/commands/<name>.md` for user scope,
90
+ * `<projectPath>/.claude/commands/<name>.md` for project).
91
+ *
92
+ * `name` may include subdirectory namespacing via `:` — e.g.
93
+ * `git:review` → file at `git/review.md` under the scope root.
94
+ * Provider validates the name (regex `[a-z][a-z0-9:-]*` typically) and
95
+ * rejects with an error when the file already exists (caller decides
96
+ * whether to retry with `overwrite`, omitted in v1 to avoid
97
+ * accidental clobbering).
98
+ */
99
+ export type CreateSlashCommandInput = {
100
+ name: string;
101
+ scope: 'user' | 'project';
102
+ description?: string;
103
+ argumentHint?: string;
104
+ body: string;
105
+ /** Required when `scope === 'project'`. */
106
+ projectPath?: string;
107
+ };
71
108
  /**
72
109
  * Parsed envelope a provider's CLI may wrap slash commands in when it logs
73
110
  * them into the session transcript. Claude uses
@@ -137,6 +174,75 @@ export type SlashCommandSupport = {
137
174
  * collisions, since it reflects the agent's actual runtime state).
138
175
  */
139
176
  subscribeToWireCommands?(sessionId: string, callback: (commands: SlashCommandDef[]) => void): () => void;
177
+ /**
178
+ * Authoring: create a new file-sourced slash command on disk. Only
179
+ * meaningful for providers that surface file-based commands (Claude
180
+ * `.claude/commands/*.md`); providers without an on-disk format leave
181
+ * this undefined and the host hides the "+ New" affordance.
182
+ *
183
+ * Contract:
184
+ * - Validates `input.name` against the provider's naming convention
185
+ * (typical regex: `[a-z][a-z0-9:-]*` with `:` for subdirectory
186
+ * namespacing).
187
+ * - Resolves the target file path under the scope root, creating
188
+ * intermediate directories as needed.
189
+ * - Refuses overwrite when the file already exists (throws an
190
+ * error with a stable code so the host can render a clear
191
+ * conflict message).
192
+ * - Writes frontmatter (`description`, `argument-hint`) plus the
193
+ * body verbatim. Returns the absolute file path.
194
+ *
195
+ * The host calls this from `provider:slash-commands:create` IPC and
196
+ * the new file is picked up by {@link subscribeFsChanges} so the
197
+ * renderer's palette refreshes without a manual reload.
198
+ */
199
+ createCommand?(input: CreateSlashCommandInput): Promise<{
200
+ filePath: string;
201
+ }>;
202
+ /**
203
+ * Authoring: delete a file-sourced slash command. The host passes the
204
+ * absolute `filePath` previously returned in a {@link SlashCommandDef}.
205
+ * `projectPath` (when provided) lets the provider validate
206
+ * project-scoped deletes too — without it, only files inside the user
207
+ * root are accepted (delete-by-path on a project file requires the
208
+ * caller to thread the project path through, which the host knows
209
+ * from the active session's cwd).
210
+ *
211
+ * Contract:
212
+ * - Verifies that `filePath` is contained inside one of the provider's
213
+ * known scope roots (path normalisation + `path.relative()` check)
214
+ * to prevent the host from accidentally requesting deletion of a
215
+ * file outside the slash-commands tree.
216
+ * - Deletes the file. Idempotent: a missing file is treated as a
217
+ * successful no-op (no `ENOENT` thrown).
218
+ *
219
+ * Like {@link createCommand}, omitting this field hides the "Delete"
220
+ * affordance for file-sourced rows in the renderer.
221
+ */
222
+ deleteCommand?(filePath: string, projectPath?: string): Promise<{
223
+ ok: true;
224
+ }>;
225
+ /**
226
+ * Subscribe to filesystem changes in the provider's user/project
227
+ * command roots. Distinct from {@link subscribeToWireCommands}: this
228
+ * is fs-driven (markdown files added/edited/deleted on disk),
229
+ * whereas the wire variant is provider-pushed runtime state.
230
+ *
231
+ * Contract:
232
+ * - The provider invokes the callback whenever a `.md` file under
233
+ * a known root is added, modified, or deleted (debounce is the
234
+ * provider's concern; the host treats the callback as "your
235
+ * cached list is stale, refetch").
236
+ * - The callback receives no payload — it's a stale-flag, not a
237
+ * diff. The host responds by re-running `scanCommands` and
238
+ * emitting `slashCommands:changed` to its renderers.
239
+ * - Returns an unsubscribe function. The host calls it on shutdown
240
+ * or provider switch.
241
+ * - Optional. Providers without a file-based source (Codex,
242
+ * Gemini today) leave this undefined and the host's cache is
243
+ * invalidated only on session boundary events.
244
+ */
245
+ subscribeFsChanges?(callback: () => void): () => void;
140
246
  };
141
247
  /**
142
248
  * Options for {@link JackProvider.readSessionTranscript}. Provider-neutral
@@ -158,6 +264,19 @@ export type ReadSessionTranscriptOptions = {
158
264
  * current consumers.
159
265
  */
160
266
  includeSystemMessages?: boolean;
267
+ /**
268
+ * Provider-config root for transcript lookup (Claude `CLAUDE_CONFIG_DIR`,
269
+ * Codex `CODEX_HOME`, …). When set, the provider reads transcripts from
270
+ * `<configDir>/<provider-native-subpath>` instead of its implicit default
271
+ * — required when the session was spawned under a non-default
272
+ * {@link ProviderProfile} so the JSONL/rollout file resolves correctly.
273
+ *
274
+ * The host resolves this from the session's pinned `profile_id` and
275
+ * passes it verbatim. Providers without a profile concept ignore the
276
+ * field; providers with profiles MUST treat it as authoritative when
277
+ * present.
278
+ */
279
+ configDir?: string;
161
280
  };
162
281
  /**
163
282
  * Provider-declared model identifiers used by host one-shot tasks. These
@@ -282,6 +401,15 @@ export type CapabilityMatrix = {
282
401
  * sandbox request returns a clear error.
283
402
  */
284
403
  sandbox: boolean;
404
+ /**
405
+ * Provider exposes a non-agentic single-shot completion via
406
+ * {@link JackProvider.oneshot}. When `false` the host hides any UI
407
+ * affordance that depends on it (e.g. CommitComposer's "AI commit
408
+ * message" button is disabled with an explanatory tooltip).
409
+ *
410
+ * When `true`, {@link JackProvider.oneshot} MUST be defined.
411
+ */
412
+ oneshot: boolean;
285
413
  /**
286
414
  * Permission modes the provider actually supports. Drives the
287
415
  * Shift-Tab cycle in the renderer (`MessageInputBar`) and any
@@ -682,6 +810,27 @@ export type JackProvider = {
682
810
  * mode for this provider's sessions.
683
811
  */
684
812
  sandbox?: SandboxApi;
813
+ /**
814
+ * One-shot completion capability — non-agentic, no tools, no session.
815
+ * See {@link OneshotApi}. Optional; when undefined `capabilities.oneshot`
816
+ * MUST be `false` and the host disables any UI affordance that relies
817
+ * on this primitive (e.g. CommitComposer's AI commit message button).
818
+ */
819
+ oneshot?: OneshotApi;
820
+ /**
821
+ * User-configurable defaults applied to newly-created sessions —
822
+ * which model, reasoning-effort tier, and permission mode the host
823
+ * should pre-fill on the session row when the user spawns a new
824
+ * session against this provider. See {@link ProviderDefaultsApi}.
825
+ *
826
+ * Optional + presence-based. A provider that omits the field doesn't
827
+ * appear in `Settings → Provider defaults` and no pre-fill happens for
828
+ * its sessions (the runtime falls back to its built-in default model /
829
+ * effort / permission_mode at spawn time). Catalog-only contract: the
830
+ * provider declares the legal values, the host owns storage (kv) and
831
+ * resolution.
832
+ */
833
+ defaults?: ProviderDefaultsApi;
685
834
  /**
686
835
  * Optional one-shot activation hook. Called once by the host during
687
836
  * registration with a {@link HostServices} bag scoped to this