dsh-taskbridge 1.7.1 → 1.8.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.
- package/CHANGELOG.md +12 -0
- package/LICENSE +21 -21
- package/README.md +149 -290
- package/THIRD_PARTY_NOTICES.txt +23 -23
- package/antigravity/agents/dsh-taskbridge.md +31 -0
- package/antigravity/skills/dsh-taskbridge/SKILL.md +51 -0
- package/codex/dsh-taskbridge.toml +170 -631
- package/cordis.patch.yml +6 -6
- package/docs/INTRODUCTION.md +119 -295
- package/docs/INTRODUCTION.zh.md +134 -279
- package/docs/antigravity-integration.md +42 -0
- package/docs/auth-contract.md +138 -138
- package/docs/claude-code.md +6 -11
- package/docs/codex-integration.md +2 -2
- package/docs/contracts-stage-b.md +443 -443
- package/docs/plugin-market.md +30 -30
- package/docs/redaction-contract.md +170 -170
- package/docs/releases/1.7.0.zh.md +11 -11
- package/docs/releases/1.8.0.zh.md +16 -0
- package/docs/runtime-compatibility.md +1 -1
- package/docs/taskbridge-upgrade.md +28 -28
- package/docs/taskdispatch-upgrade.md +25 -25
- package/docs/workspace-contract.md +538 -538
- package/docs/workspace-grouping.md +126 -126
- package/icon.svg +1 -1
- package/lib/client.d.ts +733 -699
- package/lib/client.js +7 -7
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +149 -144
- package/src/antigravity/installer.js +1046 -0
- package/src/antigravity/seam.js +142 -0
- package/src/auth/fence.js +361 -361
- package/src/auth/grants.js +789 -789
- package/src/client/api.js +143 -0
- package/src/client/index.jsx +113 -3
- package/src/client/sidebar.jsx +862 -862
- package/src/client/styles.js +624 -624
- package/src/client/task-cleanup.js +304 -304
- package/src/client/task-records-table.jsx +217 -217
- package/src/client/task-view.js +307 -307
- package/src/client/workspace-groups.js +482 -482
- package/src/client/workspaces-browser.jsx +770 -770
- package/src/codex/agent-ownership.js +270 -270
- package/src/codex/installer.js +3 -0
- package/src/codex/toml.js +784 -784
- package/src/config/redact.js +245 -245
- package/src/config/store.js +186 -186
- package/src/credentials/seam.js +202 -202
- package/src/http/respond.js +6 -5
- package/src/http/user-plane.js +72 -0
- package/src/index.js +25 -0
- package/src/jobs/diagnostics.js +15 -15
- package/src/jobs/plan-store.js +1020 -1020
- package/src/jobs/review-note.js +63 -63
- package/src/jobs/task-descriptions.js +82 -82
- package/src/jobs/task-display.js +73 -73
- package/src/jobs/task-tree.js +786 -786
- package/src/jobs/title.js +134 -134
- package/src/mcp/continuation.js +317 -317
- package/src/mcp/server.js +4 -1
- package/src/model/connectivity.js +371 -371
- package/src/model/discovery.js +582 -582
- package/src/model/native-catalog.js +68 -68
- package/src/model/openai-adapter.js +671 -671
- package/src/model/probe.js +264 -264
- package/src/model/providers.js +756 -756
- package/src/model/routing.js +321 -321
- package/src/runtime/permissions.js +1619 -1619
- package/src/runtime/question-call.js +162 -162
- package/src/runtime/questions.js +909 -909
- package/src/runtime/worker-prompt.js +60 -55
- package/src/workspace/audit.js +775 -775
- package/src/workspace/preflight.js +424 -424
- package/src/workspace/worktrees.js +679 -679
package/src/credentials/seam.js
CHANGED
|
@@ -1,202 +1,202 @@
|
|
|
1
|
-
// Credential seam gateway.
|
|
2
|
-
//
|
|
3
|
-
// The plugin never stores a secret and never reads one back into a projection.
|
|
4
|
-
// It talks to the native DSH credential seam (`ctx.credentials`) for exactly four
|
|
5
|
-
// operations and nothing else:
|
|
6
|
-
//
|
|
7
|
-
// * `describe(ref)` — presence/source/writability, safe for a settings UI;
|
|
8
|
-
// * `resolve(ref)` — the value, for the native adapter inside a stream call;
|
|
9
|
-
// * `set(ref, value)` — write one value the operator pasted;
|
|
10
|
-
// * `unset(ref)` — remove it.
|
|
11
|
-
//
|
|
12
|
-
// The seam is reached through a *lazy* accessor rather than a captured reference.
|
|
13
|
-
// Two reasons, both about load order:
|
|
14
|
-
//
|
|
15
|
-
// 1. this plugin deliberately does not inject the credential service, so it
|
|
16
|
-
// loads and reports state in a harness that has none (the UI then says
|
|
17
|
-
// "host provides no credential interface" instead of the plugin refusing to
|
|
18
|
-
// start); and
|
|
19
|
-
// 2. the seam documents a per-operation resolve so a rotated credential reaches
|
|
20
|
-
// the next operation without a restart — capturing the service object once
|
|
21
|
-
// would still be fine, but capturing the *value* would not, and the lazy
|
|
22
|
-
// read makes that mistake impossible to write here.
|
|
23
|
-
//
|
|
24
|
-
// A failed seam call is reported with its own code and a bounded `cause` code.
|
|
25
|
-
// The provider's message is never forwarded: a credential backend is free to echo
|
|
26
|
-
// what it was given, and this is the one place in the plugin where that would be
|
|
27
|
-
// a disclosure.
|
|
28
|
-
|
|
29
|
-
/** Stable refusal codes for every credential operation. */
|
|
30
|
-
export const CREDENTIAL_CODES = Object.freeze({
|
|
31
|
-
seamUnavailable: 'CREDENTIAL_SEAM_UNAVAILABLE',
|
|
32
|
-
operationFailed: 'CREDENTIAL_OPERATION_FAILED',
|
|
33
|
-
readOnly: 'CREDENTIAL_READ_ONLY',
|
|
34
|
-
valueRequired: 'CREDENTIAL_VALUE_REQUIRED',
|
|
35
|
-
valueTooLarge: 'CREDENTIAL_VALUE_TOO_LARGE',
|
|
36
|
-
refInvalid: 'CREDENTIAL_REF_INVALID',
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
/** Bound on a pasted secret. A provider key is far shorter than this. */
|
|
40
|
-
export const MAX_CREDENTIAL_VALUE_CHARS = 8192;
|
|
41
|
-
|
|
42
|
-
/** A credential refusal with a stable machine code. */
|
|
43
|
-
export class CredentialSeamError extends Error {
|
|
44
|
-
/**
|
|
45
|
-
* @param {string} code - stable machine code.
|
|
46
|
-
* @param {string} message - human-readable explanation.
|
|
47
|
-
* @param {object} [details] - bounded, non-secret details.
|
|
48
|
-
*/
|
|
49
|
-
constructor(code, message, details = {}) {
|
|
50
|
-
super(message);
|
|
51
|
-
this.name = 'CredentialSeamError';
|
|
52
|
-
this.code = code;
|
|
53
|
-
this.details = details;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/** Methods the seam must expose for this plugin to act at all. */
|
|
58
|
-
const REQUIRED_METHODS = Object.freeze({
|
|
59
|
-
resolve: 'resolve',
|
|
60
|
-
describe: 'describe',
|
|
61
|
-
set: 'set',
|
|
62
|
-
unset: 'unset',
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Create the credential gateway over one native service accessor.
|
|
67
|
-
* @param {() => unknown} getService - returns the current `ctx.credentials`, or a
|
|
68
|
-
* nullish value while the service is absent.
|
|
69
|
-
* @returns {{ available: () => boolean, describe: Function, resolve: Function, set: Function, unset: Function }} gateway.
|
|
70
|
-
*/
|
|
71
|
-
export function createCredentialGateway(getService) {
|
|
72
|
-
if (typeof getService !== 'function') {
|
|
73
|
-
throw new TypeError('createCredentialGateway needs a service accessor');
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Read the seam, refusing rather than returning null so a caller can never
|
|
78
|
-
* mistake "no service" for "no credential".
|
|
79
|
-
* @param {string} operation - seam method being attempted, for the refusal.
|
|
80
|
-
* @returns {object} the native service.
|
|
81
|
-
*/
|
|
82
|
-
function requireSeam(operation) {
|
|
83
|
-
let service;
|
|
84
|
-
try {
|
|
85
|
-
service = getService();
|
|
86
|
-
} catch (error) {
|
|
87
|
-
// A host whose accessor throws is a refusal, not a crash inside a route.
|
|
88
|
-
throw new CredentialSeamError(CREDENTIAL_CODES.seamUnavailable,
|
|
89
|
-
'the DSH credential service could not be read in this harness',
|
|
90
|
-
{ operation, cause: typeof error?.code === 'string' ? error.code : null });
|
|
91
|
-
}
|
|
92
|
-
if (service === null || typeof service !== 'object') {
|
|
93
|
-
throw new CredentialSeamError(CREDENTIAL_CODES.seamUnavailable,
|
|
94
|
-
'this harness exposes no credential service; a pasted secret cannot be stored',
|
|
95
|
-
{ operation });
|
|
96
|
-
}
|
|
97
|
-
const method = REQUIRED_METHODS[operation];
|
|
98
|
-
if (typeof service[method] !== 'function') {
|
|
99
|
-
throw new CredentialSeamError(CREDENTIAL_CODES.seamUnavailable,
|
|
100
|
-
`the credential service does not implement ${method}()`,
|
|
101
|
-
{ operation });
|
|
102
|
-
}
|
|
103
|
-
return service;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Run one seam call, translating a provider failure into a bounded refusal.
|
|
108
|
-
* @param {string} operation - seam method name.
|
|
109
|
-
* @param {string} ref - credential reference, echoed as a name only.
|
|
110
|
-
* @param {(service: object) => Promise<unknown>} work - the call.
|
|
111
|
-
* @returns {Promise<unknown>} the seam result.
|
|
112
|
-
*/
|
|
113
|
-
async function attempt(operation, ref, work) {
|
|
114
|
-
const service = requireSeam(operation);
|
|
115
|
-
try {
|
|
116
|
-
return await work(service);
|
|
117
|
-
} catch (error) {
|
|
118
|
-
if (error instanceof CredentialSeamError) throw error;
|
|
119
|
-
// Only the code survives: the message may quote the value or a path.
|
|
120
|
-
throw new CredentialSeamError(CREDENTIAL_CODES.operationFailed,
|
|
121
|
-
`the credential service refused ${operation}() for ${ref}`,
|
|
122
|
-
{ operation, reference: ref, cause: typeof error?.code === 'string' ? error.code : null });
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return {
|
|
127
|
-
/**
|
|
128
|
-
* Whether the seam is present at all, for status reporting.
|
|
129
|
-
* @returns {boolean} true when `resolve` is callable.
|
|
130
|
-
*/
|
|
131
|
-
available() {
|
|
132
|
-
try {
|
|
133
|
-
requireSeam('resolve');
|
|
134
|
-
return true;
|
|
135
|
-
} catch {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Presence/source/writability for one reference. The returned view has no
|
|
142
|
-
* slot a value could ride in, and this function does not add one.
|
|
143
|
-
* @param {string} ref - credential reference name.
|
|
144
|
-
* @returns {Promise<{ configured: boolean, source?: string, writable: boolean }>} seam view.
|
|
145
|
-
*/
|
|
146
|
-
async describe(ref) {
|
|
147
|
-
const info = await attempt('describe', ref, (service) => service.describe(ref));
|
|
148
|
-
if (info === null || typeof info !== 'object') {
|
|
149
|
-
throw new CredentialSeamError(CREDENTIAL_CODES.operationFailed,
|
|
150
|
-
`the credential service returned no usable description for ${ref}`,
|
|
151
|
-
{ operation: 'describe', reference: ref });
|
|
152
|
-
}
|
|
153
|
-
return {
|
|
154
|
-
configured: info.configured === true,
|
|
155
|
-
...(typeof info.source === 'string' && info.source !== '' ? { source: info.source } : {}),
|
|
156
|
-
writable: info.writable === true,
|
|
157
|
-
};
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Resolve one reference to its current value. Called only by the native
|
|
162
|
-
* adapter inside a stream operation; the value is returned to pi-ai and to
|
|
163
|
-
* nothing else.
|
|
164
|
-
* @param {string} ref - credential reference name.
|
|
165
|
-
* @returns {Promise<{ value: string, source: string } | undefined>} value, or undefined.
|
|
166
|
-
*/
|
|
167
|
-
async resolve(ref) {
|
|
168
|
-
return await attempt('resolve', ref, (service) => service.resolve(ref));
|
|
169
|
-
},
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Store one pasted value. Refuses an empty value (that is `unset`) and a
|
|
173
|
-
* value no provider key could be.
|
|
174
|
-
* @param {string} ref - credential reference name.
|
|
175
|
-
* @param {string} value - the literal secret.
|
|
176
|
-
* @returns {Promise<void>} resolves after the seam committed the write.
|
|
177
|
-
*/
|
|
178
|
-
async set(ref, value) {
|
|
179
|
-
if (typeof value !== 'string' || value.trim() === '') {
|
|
180
|
-
throw new CredentialSeamError(CREDENTIAL_CODES.valueRequired,
|
|
181
|
-
'a credential value is required; use clear to remove one', { reference: ref });
|
|
182
|
-
}
|
|
183
|
-
if (value.length > MAX_CREDENTIAL_VALUE_CHARS) {
|
|
184
|
-
throw new CredentialSeamError(CREDENTIAL_CODES.valueTooLarge,
|
|
185
|
-
'the credential value exceeds the accepted bound',
|
|
186
|
-
{ reference: ref, limit: MAX_CREDENTIAL_VALUE_CHARS });
|
|
187
|
-
}
|
|
188
|
-
// The literal is not trimmed: a trailing space would be a different secret,
|
|
189
|
-
// and silently altering what the operator pasted would be a hidden failure.
|
|
190
|
-
await attempt('set', ref, (service) => service.set(ref, value));
|
|
191
|
-
},
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Remove one stored value. Removing an absent value is a no-op in the seam.
|
|
195
|
-
* @param {string} ref - credential reference name.
|
|
196
|
-
* @returns {Promise<void>} resolves after the seam committed the removal.
|
|
197
|
-
*/
|
|
198
|
-
async unset(ref) {
|
|
199
|
-
await attempt('unset', ref, (service) => service.unset(ref));
|
|
200
|
-
},
|
|
201
|
-
};
|
|
202
|
-
}
|
|
1
|
+
// Credential seam gateway.
|
|
2
|
+
//
|
|
3
|
+
// The plugin never stores a secret and never reads one back into a projection.
|
|
4
|
+
// It talks to the native DSH credential seam (`ctx.credentials`) for exactly four
|
|
5
|
+
// operations and nothing else:
|
|
6
|
+
//
|
|
7
|
+
// * `describe(ref)` — presence/source/writability, safe for a settings UI;
|
|
8
|
+
// * `resolve(ref)` — the value, for the native adapter inside a stream call;
|
|
9
|
+
// * `set(ref, value)` — write one value the operator pasted;
|
|
10
|
+
// * `unset(ref)` — remove it.
|
|
11
|
+
//
|
|
12
|
+
// The seam is reached through a *lazy* accessor rather than a captured reference.
|
|
13
|
+
// Two reasons, both about load order:
|
|
14
|
+
//
|
|
15
|
+
// 1. this plugin deliberately does not inject the credential service, so it
|
|
16
|
+
// loads and reports state in a harness that has none (the UI then says
|
|
17
|
+
// "host provides no credential interface" instead of the plugin refusing to
|
|
18
|
+
// start); and
|
|
19
|
+
// 2. the seam documents a per-operation resolve so a rotated credential reaches
|
|
20
|
+
// the next operation without a restart — capturing the service object once
|
|
21
|
+
// would still be fine, but capturing the *value* would not, and the lazy
|
|
22
|
+
// read makes that mistake impossible to write here.
|
|
23
|
+
//
|
|
24
|
+
// A failed seam call is reported with its own code and a bounded `cause` code.
|
|
25
|
+
// The provider's message is never forwarded: a credential backend is free to echo
|
|
26
|
+
// what it was given, and this is the one place in the plugin where that would be
|
|
27
|
+
// a disclosure.
|
|
28
|
+
|
|
29
|
+
/** Stable refusal codes for every credential operation. */
|
|
30
|
+
export const CREDENTIAL_CODES = Object.freeze({
|
|
31
|
+
seamUnavailable: 'CREDENTIAL_SEAM_UNAVAILABLE',
|
|
32
|
+
operationFailed: 'CREDENTIAL_OPERATION_FAILED',
|
|
33
|
+
readOnly: 'CREDENTIAL_READ_ONLY',
|
|
34
|
+
valueRequired: 'CREDENTIAL_VALUE_REQUIRED',
|
|
35
|
+
valueTooLarge: 'CREDENTIAL_VALUE_TOO_LARGE',
|
|
36
|
+
refInvalid: 'CREDENTIAL_REF_INVALID',
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
/** Bound on a pasted secret. A provider key is far shorter than this. */
|
|
40
|
+
export const MAX_CREDENTIAL_VALUE_CHARS = 8192;
|
|
41
|
+
|
|
42
|
+
/** A credential refusal with a stable machine code. */
|
|
43
|
+
export class CredentialSeamError extends Error {
|
|
44
|
+
/**
|
|
45
|
+
* @param {string} code - stable machine code.
|
|
46
|
+
* @param {string} message - human-readable explanation.
|
|
47
|
+
* @param {object} [details] - bounded, non-secret details.
|
|
48
|
+
*/
|
|
49
|
+
constructor(code, message, details = {}) {
|
|
50
|
+
super(message);
|
|
51
|
+
this.name = 'CredentialSeamError';
|
|
52
|
+
this.code = code;
|
|
53
|
+
this.details = details;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Methods the seam must expose for this plugin to act at all. */
|
|
58
|
+
const REQUIRED_METHODS = Object.freeze({
|
|
59
|
+
resolve: 'resolve',
|
|
60
|
+
describe: 'describe',
|
|
61
|
+
set: 'set',
|
|
62
|
+
unset: 'unset',
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Create the credential gateway over one native service accessor.
|
|
67
|
+
* @param {() => unknown} getService - returns the current `ctx.credentials`, or a
|
|
68
|
+
* nullish value while the service is absent.
|
|
69
|
+
* @returns {{ available: () => boolean, describe: Function, resolve: Function, set: Function, unset: Function }} gateway.
|
|
70
|
+
*/
|
|
71
|
+
export function createCredentialGateway(getService) {
|
|
72
|
+
if (typeof getService !== 'function') {
|
|
73
|
+
throw new TypeError('createCredentialGateway needs a service accessor');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Read the seam, refusing rather than returning null so a caller can never
|
|
78
|
+
* mistake "no service" for "no credential".
|
|
79
|
+
* @param {string} operation - seam method being attempted, for the refusal.
|
|
80
|
+
* @returns {object} the native service.
|
|
81
|
+
*/
|
|
82
|
+
function requireSeam(operation) {
|
|
83
|
+
let service;
|
|
84
|
+
try {
|
|
85
|
+
service = getService();
|
|
86
|
+
} catch (error) {
|
|
87
|
+
// A host whose accessor throws is a refusal, not a crash inside a route.
|
|
88
|
+
throw new CredentialSeamError(CREDENTIAL_CODES.seamUnavailable,
|
|
89
|
+
'the DSH credential service could not be read in this harness',
|
|
90
|
+
{ operation, cause: typeof error?.code === 'string' ? error.code : null });
|
|
91
|
+
}
|
|
92
|
+
if (service === null || typeof service !== 'object') {
|
|
93
|
+
throw new CredentialSeamError(CREDENTIAL_CODES.seamUnavailable,
|
|
94
|
+
'this harness exposes no credential service; a pasted secret cannot be stored',
|
|
95
|
+
{ operation });
|
|
96
|
+
}
|
|
97
|
+
const method = REQUIRED_METHODS[operation];
|
|
98
|
+
if (typeof service[method] !== 'function') {
|
|
99
|
+
throw new CredentialSeamError(CREDENTIAL_CODES.seamUnavailable,
|
|
100
|
+
`the credential service does not implement ${method}()`,
|
|
101
|
+
{ operation });
|
|
102
|
+
}
|
|
103
|
+
return service;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Run one seam call, translating a provider failure into a bounded refusal.
|
|
108
|
+
* @param {string} operation - seam method name.
|
|
109
|
+
* @param {string} ref - credential reference, echoed as a name only.
|
|
110
|
+
* @param {(service: object) => Promise<unknown>} work - the call.
|
|
111
|
+
* @returns {Promise<unknown>} the seam result.
|
|
112
|
+
*/
|
|
113
|
+
async function attempt(operation, ref, work) {
|
|
114
|
+
const service = requireSeam(operation);
|
|
115
|
+
try {
|
|
116
|
+
return await work(service);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
if (error instanceof CredentialSeamError) throw error;
|
|
119
|
+
// Only the code survives: the message may quote the value or a path.
|
|
120
|
+
throw new CredentialSeamError(CREDENTIAL_CODES.operationFailed,
|
|
121
|
+
`the credential service refused ${operation}() for ${ref}`,
|
|
122
|
+
{ operation, reference: ref, cause: typeof error?.code === 'string' ? error.code : null });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
/**
|
|
128
|
+
* Whether the seam is present at all, for status reporting.
|
|
129
|
+
* @returns {boolean} true when `resolve` is callable.
|
|
130
|
+
*/
|
|
131
|
+
available() {
|
|
132
|
+
try {
|
|
133
|
+
requireSeam('resolve');
|
|
134
|
+
return true;
|
|
135
|
+
} catch {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Presence/source/writability for one reference. The returned view has no
|
|
142
|
+
* slot a value could ride in, and this function does not add one.
|
|
143
|
+
* @param {string} ref - credential reference name.
|
|
144
|
+
* @returns {Promise<{ configured: boolean, source?: string, writable: boolean }>} seam view.
|
|
145
|
+
*/
|
|
146
|
+
async describe(ref) {
|
|
147
|
+
const info = await attempt('describe', ref, (service) => service.describe(ref));
|
|
148
|
+
if (info === null || typeof info !== 'object') {
|
|
149
|
+
throw new CredentialSeamError(CREDENTIAL_CODES.operationFailed,
|
|
150
|
+
`the credential service returned no usable description for ${ref}`,
|
|
151
|
+
{ operation: 'describe', reference: ref });
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
configured: info.configured === true,
|
|
155
|
+
...(typeof info.source === 'string' && info.source !== '' ? { source: info.source } : {}),
|
|
156
|
+
writable: info.writable === true,
|
|
157
|
+
};
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Resolve one reference to its current value. Called only by the native
|
|
162
|
+
* adapter inside a stream operation; the value is returned to pi-ai and to
|
|
163
|
+
* nothing else.
|
|
164
|
+
* @param {string} ref - credential reference name.
|
|
165
|
+
* @returns {Promise<{ value: string, source: string } | undefined>} value, or undefined.
|
|
166
|
+
*/
|
|
167
|
+
async resolve(ref) {
|
|
168
|
+
return await attempt('resolve', ref, (service) => service.resolve(ref));
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Store one pasted value. Refuses an empty value (that is `unset`) and a
|
|
173
|
+
* value no provider key could be.
|
|
174
|
+
* @param {string} ref - credential reference name.
|
|
175
|
+
* @param {string} value - the literal secret.
|
|
176
|
+
* @returns {Promise<void>} resolves after the seam committed the write.
|
|
177
|
+
*/
|
|
178
|
+
async set(ref, value) {
|
|
179
|
+
if (typeof value !== 'string' || value.trim() === '') {
|
|
180
|
+
throw new CredentialSeamError(CREDENTIAL_CODES.valueRequired,
|
|
181
|
+
'a credential value is required; use clear to remove one', { reference: ref });
|
|
182
|
+
}
|
|
183
|
+
if (value.length > MAX_CREDENTIAL_VALUE_CHARS) {
|
|
184
|
+
throw new CredentialSeamError(CREDENTIAL_CODES.valueTooLarge,
|
|
185
|
+
'the credential value exceeds the accepted bound',
|
|
186
|
+
{ reference: ref, limit: MAX_CREDENTIAL_VALUE_CHARS });
|
|
187
|
+
}
|
|
188
|
+
// The literal is not trimmed: a trailing space would be a different secret,
|
|
189
|
+
// and silently altering what the operator pasted would be a hidden failure.
|
|
190
|
+
await attempt('set', ref, (service) => service.set(ref, value));
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Remove one stored value. Removing an absent value is a no-op in the seam.
|
|
195
|
+
* @param {string} ref - credential reference name.
|
|
196
|
+
* @returns {Promise<void>} resolves after the seam committed the removal.
|
|
197
|
+
*/
|
|
198
|
+
async unset(ref) {
|
|
199
|
+
await attempt('unset', ref, (service) => service.unset(ref));
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
}
|
package/src/http/respond.js
CHANGED
|
@@ -190,11 +190,12 @@ function statusForCode(code) {
|
|
|
190
190
|
if (code === 'CREDENTIAL_OPERATION_FAILED' || code === 'CREDENTIAL_READ_ONLY') return 502;
|
|
191
191
|
if (code === 'CREDENTIAL_VALUE_REQUIRED' || code === 'CREDENTIAL_VALUE_TOO_LARGE' || code === 'CREDENTIAL_REF_INVALID') return 400;
|
|
192
192
|
if (code.startsWith('CREDENTIAL_')) return 409;
|
|
193
|
-
// Codex
|
|
194
|
-
// refusal to touch it is a state conflict, and a malformed request a 400.
|
|
195
|
-
if (code === 'CODEX_INTEGRATION_UNAVAILABLE') return 503;
|
|
196
|
-
if (code === 'CODEX_HOME_INVALID' || code === 'CODEX_ACTION_INVALID'
|
|
197
|
-
|
|
193
|
+
// Codex & Antigravity integrations: the operator's own home/config is the subject,
|
|
194
|
+
// so a refusal to touch it is a state conflict, and a malformed request a 400.
|
|
195
|
+
if (code === 'CODEX_INTEGRATION_UNAVAILABLE' || code === 'ANTIGRAVITY_INTEGRATION_UNAVAILABLE') return 503;
|
|
196
|
+
if (code === 'CODEX_HOME_INVALID' || code === 'CODEX_ACTION_INVALID'
|
|
197
|
+
|| code === 'ANTIGRAVITY_HOME_INVALID' || code === 'ANTIGRAVITY_ACTION_INVALID') return 400;
|
|
198
|
+
if (code.startsWith('CODEX_') || code.startsWith('ANTIGRAVITY_') || code.startsWith('MCP_') || code.startsWith('AGENT_')) return 409;
|
|
198
199
|
if (code === 'BODY_TOO_LARGE') return 413;
|
|
199
200
|
if (code === 'BODY_INVALID_JSON' || code === 'BODY_NOT_OBJECT') return 400;
|
|
200
201
|
return 400;
|
package/src/http/user-plane.js
CHANGED
|
@@ -36,6 +36,7 @@ import { discoverProviderModels } from '../model/discovery.js';
|
|
|
36
36
|
import { checkProviderConnectivity } from '../model/connectivity.js';
|
|
37
37
|
import { MAX_CREDENTIAL_VALUE_CHARS } from '../credentials/seam.js';
|
|
38
38
|
import { CODEX_ACTIONS, publicCodexStatus, runCodexAction } from '../codex/installer.js';
|
|
39
|
+
import { ANTIGRAVITY_ACTIONS, publicAntigravityStatus } from '../antigravity/installer.js';
|
|
39
40
|
import { classifyError, HttpError, jsonResponse, readJsonRequest } from '../http/respond.js';
|
|
40
41
|
import { sameRecordedDirectory } from '../jobs/continuation-identity.js';
|
|
41
42
|
import { buildTaskTree } from '../jobs/task-tree.js';
|
|
@@ -817,6 +818,41 @@ export function userPlaneRoutes(deps) {
|
|
|
817
818
|
},
|
|
818
819
|
},
|
|
819
820
|
|
|
821
|
+
// ---- Antigravity integration -------------------------------------------
|
|
822
|
+
// Same authenticated operator plane contract as `/codex`:
|
|
823
|
+
// GET /antigravity — read-only diagnosis (never writes);
|
|
824
|
+
// POST /antigravity — explicit `install`, `repair` or `remove`.
|
|
825
|
+
{
|
|
826
|
+
path: `${USER_PLANE_PREFIX}/antigravity`,
|
|
827
|
+
methods: ['GET', 'POST'],
|
|
828
|
+
requestBody: BODY_MODE,
|
|
829
|
+
fetch: async (request) => {
|
|
830
|
+
const method = String(request.method ?? 'GET').toUpperCase();
|
|
831
|
+
if (method === 'GET') {
|
|
832
|
+
const outcome = await runAntigravityIntegration(deps, 'status');
|
|
833
|
+
return jsonResponse(200, { ok: true, ...outcome });
|
|
834
|
+
}
|
|
835
|
+
if (method !== 'POST') return methodRefusal(request, ['GET', 'POST']);
|
|
836
|
+
const body = await readJsonRequest(request);
|
|
837
|
+
const action = typeof body.action === 'string' ? body.action.trim() : '';
|
|
838
|
+
if (!ANTIGRAVITY_ACTIONS.includes(action) || action === 'status') {
|
|
839
|
+
throw new HttpError(
|
|
840
|
+
400,
|
|
841
|
+
'ANTIGRAVITY_ACTION_INVALID',
|
|
842
|
+
`action must be one of ${ANTIGRAVITY_ACTIONS.filter((entry) => entry !== 'status').join(', ')}`,
|
|
843
|
+
{ allowed: ANTIGRAVITY_ACTIONS.filter((entry) => entry !== 'status') },
|
|
844
|
+
);
|
|
845
|
+
}
|
|
846
|
+
const outcome = await runAntigravityIntegration(deps, action);
|
|
847
|
+
deps.logger?.info?.('dsh-delegate: Antigravity integration action applied', {
|
|
848
|
+
action,
|
|
849
|
+
changed: outcome.changed,
|
|
850
|
+
refused: outcome.refused.map((entry) => entry.code),
|
|
851
|
+
});
|
|
852
|
+
return jsonResponse(200, { ok: true, ...outcome });
|
|
853
|
+
},
|
|
854
|
+
},
|
|
855
|
+
|
|
820
856
|
// ---- layered connectivity ---------------------------------------------
|
|
821
857
|
// One provider per request. The report is the four-layer structure documented
|
|
822
858
|
// in `docs/native-integration-audit.md`; a layer that was not attempted is
|
|
@@ -909,6 +945,42 @@ async function runCodexIntegration(deps, action) {
|
|
|
909
945
|
};
|
|
910
946
|
}
|
|
911
947
|
|
|
948
|
+
async function runAntigravityIntegration(deps, action) {
|
|
949
|
+
const seam = deps.antigravity;
|
|
950
|
+
if (seam === null || seam === undefined || typeof seam.run !== 'function' || typeof seam.status !== 'function') {
|
|
951
|
+
throw new HttpError(
|
|
952
|
+
503,
|
|
953
|
+
'ANTIGRAVITY_INTEGRATION_UNAVAILABLE',
|
|
954
|
+
'this host does not expose the Antigravity integration, so nothing can be installed or reported',
|
|
955
|
+
);
|
|
956
|
+
}
|
|
957
|
+
let outcome;
|
|
958
|
+
try {
|
|
959
|
+
outcome = action === 'status' ? await seam.status() : await seam.run(action);
|
|
960
|
+
} catch (error) {
|
|
961
|
+
const code = typeof error?.code === 'string' ? error.code : 'ANTIGRAVITY_INTEGRATION_FAILED';
|
|
962
|
+
throw new HttpError(
|
|
963
|
+
code === 'ANTIGRAVITY_HOME_INVALID' ? 400 : code === 'ANTIGRAVITY_PATH_CONFLICT' ? 409 : 500,
|
|
964
|
+
code,
|
|
965
|
+
typeof error?.message === 'string' ? error.message : 'the Antigravity integration action failed',
|
|
966
|
+
error?.details !== undefined && error.details !== null ? error.details : {},
|
|
967
|
+
);
|
|
968
|
+
}
|
|
969
|
+
const switchPosture = typeof deps.engine?.posture === 'function' ? deps.engine.posture() : null;
|
|
970
|
+
return {
|
|
971
|
+
action,
|
|
972
|
+
changed: Array.isArray(outcome?.changed) ? outcome.changed : [],
|
|
973
|
+
refused: Array.isArray(outcome?.refused) ? outcome.refused : [],
|
|
974
|
+
antigravity: redactDeep(publicAntigravityStatus(outcome?.status ?? {})),
|
|
975
|
+
switch: {
|
|
976
|
+
authorized: switchPosture?.authorized === true,
|
|
977
|
+
mode: switchPosture?.mode ?? 'switch',
|
|
978
|
+
reason: switchPosture?.reason ?? null,
|
|
979
|
+
changedByThisAction: false,
|
|
980
|
+
},
|
|
981
|
+
};
|
|
982
|
+
}
|
|
983
|
+
|
|
912
984
|
// ---- task-record projection (live engine + durable archive) ----------------
|
|
913
985
|
|
|
914
986
|
/**
|
package/src/index.js
CHANGED
|
@@ -58,6 +58,7 @@ import { diagnostic } from './runtime/agent-runner.js';
|
|
|
58
58
|
import { ensureWorkspace, SessionStore, liveControllerAccessor } from './runtime/session-placement.js';
|
|
59
59
|
import { publishRuntimeEndpoint, resolveDefaultEndpointDiscoveryPath } from './runtime/endpoint-discovery.js';
|
|
60
60
|
import { resolveCodexActionSeam } from './codex/seam.js';
|
|
61
|
+
import { resolveAntigravityActionSeam } from './antigravity/seam.js';
|
|
61
62
|
import { configureDelegatedSession, policyServicesOf } from './runtime/sandbox.js';
|
|
62
63
|
import { PermissionBridge, PERMISSION_DEFAULT_TIMEOUT_MS } from './runtime/permissions.js';
|
|
63
64
|
import { QuestionBridge } from './runtime/questions.js';
|
|
@@ -267,6 +268,9 @@ export async function apply(ctx, config = {}) {
|
|
|
267
268
|
// always has a place to keep the original bytes.
|
|
268
269
|
backupDir: join(dataDir, 'codex-config-backup'),
|
|
269
270
|
}),
|
|
271
|
+
antigravity: resolveAntigravityActionSeam({
|
|
272
|
+
version: pluginVersion,
|
|
273
|
+
}),
|
|
270
274
|
configureDelegatedSession,
|
|
271
275
|
// `ctx.sandboxPolicy` and `ctx.approval` own the two facts the delegated
|
|
272
276
|
// policy writes, so the runner reads them back through these live services
|
|
@@ -332,6 +336,27 @@ export async function apply(ctx, config = {}) {
|
|
|
332
336
|
logger?.warn?.(`dsh-delegate: Codex integration refresh check failed (${diagnostic(error?.message ?? error, 200)})`);
|
|
333
337
|
}
|
|
334
338
|
|
|
339
|
+
try {
|
|
340
|
+
const agyTarget = await deps.antigravity?.startupTarget?.();
|
|
341
|
+
let agyMigration = null;
|
|
342
|
+
if (agyTarget?.home) {
|
|
343
|
+
agyMigration = await deps.antigravity?.refreshManagedIntegration({ startupTarget: agyTarget });
|
|
344
|
+
} else if (agyTarget !== undefined && agyTarget !== null) {
|
|
345
|
+
logger?.info?.(`dsh-delegate: Antigravity integration check skipped (${agyTarget.reason})`);
|
|
346
|
+
}
|
|
347
|
+
if (agyMigration?.changed.includes('plugin')) {
|
|
348
|
+
logger?.info?.(`dsh-delegate: refreshed a managed Antigravity plugin bundle to ${pluginVersion}`);
|
|
349
|
+
}
|
|
350
|
+
if (agyMigration?.changed.includes('mcp')) {
|
|
351
|
+
logger?.info?.('dsh-delegate: upgraded a stale managed Antigravity MCP entry in place');
|
|
352
|
+
}
|
|
353
|
+
for (const refusal of agyMigration?.refused ?? []) {
|
|
354
|
+
logger?.warn?.(`dsh-delegate: Antigravity integration refresh was refused (${refusal.code})`);
|
|
355
|
+
}
|
|
356
|
+
} catch (error) {
|
|
357
|
+
logger?.warn?.(`dsh-delegate: Antigravity integration refresh check failed (${diagnostic(error?.message ?? error, 200)})`);
|
|
358
|
+
}
|
|
359
|
+
|
|
335
360
|
/**
|
|
336
361
|
* Bring the native routes and the adapter's served snapshot to the state this
|
|
337
362
|
* settings snapshot describes, and return the mapping both sides agree on.
|
package/src/jobs/diagnostics.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
// Closed vocabulary shared by the activity monitor and the MCP wait answer.
|
|
2
|
-
//
|
|
3
|
-
// This module exists only to hold string constants that BOTH sides compare, so the
|
|
4
|
-
// producer and the consumer cannot drift apart, and so neither has to import the other.
|
|
5
|
-
// It has no imports of its own: it is the leaf of the graph, which is what keeps the
|
|
6
|
-
// `server ⇄ wait` pair and the engine from forming a cycle over one literal.
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* `failure.kind` for a repeated-tool-failure reminder.
|
|
10
|
-
*
|
|
11
|
-
* The reminder rides the existing `attention` reason rather than adding a new one; this
|
|
12
|
-
* discriminator is what lets a host tell "silent for the configured interval" from "kept
|
|
13
|
-
* failing the same operation", which need different decisions.
|
|
14
|
-
*/
|
|
15
|
-
export const REPEATED_FAILURE_KIND = 'repeated-tool-failure';
|
|
1
|
+
// Closed vocabulary shared by the activity monitor and the MCP wait answer.
|
|
2
|
+
//
|
|
3
|
+
// This module exists only to hold string constants that BOTH sides compare, so the
|
|
4
|
+
// producer and the consumer cannot drift apart, and so neither has to import the other.
|
|
5
|
+
// It has no imports of its own: it is the leaf of the graph, which is what keeps the
|
|
6
|
+
// `server ⇄ wait` pair and the engine from forming a cycle over one literal.
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* `failure.kind` for a repeated-tool-failure reminder.
|
|
10
|
+
*
|
|
11
|
+
* The reminder rides the existing `attention` reason rather than adding a new one; this
|
|
12
|
+
* discriminator is what lets a host tell "silent for the configured interval" from "kept
|
|
13
|
+
* failing the same operation", which need different decisions.
|
|
14
|
+
*/
|
|
15
|
+
export const REPEATED_FAILURE_KIND = 'repeated-tool-failure';
|