@intutic/clawde 2.2.0 → 2.3.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/README.md +5 -3
- package/dist/client.d.ts +26 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +90 -14
- package/dist/client.js.map +1 -1
- package/dist/control-plane.d.ts +19 -3
- package/dist/control-plane.d.ts.map +1 -1
- package/dist/control-plane.js +24 -2
- package/dist/control-plane.js.map +1 -1
- package/dist/errors.d.ts +7 -3
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +8 -3
- package/dist/errors.js.map +1 -1
- package/dist/git-context.d.ts +27 -0
- package/dist/git-context.d.ts.map +1 -0
- package/dist/git-context.js +114 -0
- package/dist/git-context.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/refusals.d.ts +39 -15
- package/dist/refusals.d.ts.map +1 -1
- package/dist/refusals.js +68 -16
- package/dist/refusals.js.map +1 -1
- package/dist/types.d.ts +16 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,13 +10,15 @@ npm install @intutic/clawde
|
|
|
10
10
|
|
|
11
11
|
## Features
|
|
12
12
|
|
|
13
|
-
- **Governed chat:** `chat()` sends a request through the proxy and resolves with `verdict: 'allow'`. A governance refusal (policy block, reask, loop run held for review, spend cap, DLP block) throws `ClawdeBlockedError` with the proxy's `verdict`, `code` and reason, and is never retried; transport failures and 5xx answers are retried.
|
|
14
|
-
- **
|
|
13
|
+
- **Governed chat:** `chat()` sends a request through the proxy and resolves with `verdict: 'allow'`. A governance refusal (policy block, reask, loop run held for review, spend cap, DLP block) throws `ClawdeBlockedError` with the proxy's `verdict`, `code`, `ruleId` (when the proxy names the rule) and reason, and is never retried; transport failures and 5xx answers are retried.
|
|
14
|
+
- **Withheld tool calls:** when the proxy withholds a tool call from the model's answer (a tool an SOP denies, the SSO group policy, destructive SQL, sensitive output), the answer arrives as a 200 that names the refusal in the `x-intutic-refusal` and `x-intutic-refusal-rule` headers. `chat()` reads them and throws `ClawdeBlockedError` too. For a stream you read yourself, pass each line to `streamRefusal()`, which finds the `: intutic-refusal` marker the proxy writes before the refusal text. See [Verdicts and Errors](https://docs.intutic.ai/reference/clawde-sdk#_5-verdicts-and-errors) for every refusal code.
|
|
15
|
+
- **Verdict Events:** `client.on('kill' | 'reask' | 'hold', ...)` fires on a refusal, before `chat()` throws.
|
|
15
16
|
- **Anthropic requests:** `provider: 'anthropic'` translates OpenAI-style parameters to an Anthropic Messages body, sends it to the proxy's `/v1/messages` route, and translates the reply back.
|
|
16
17
|
- **Budget Check:** `checkBudget()` reports whether the workspace has budget left, from the control plane's `GET /api/v1/budget`.
|
|
17
18
|
- **Circuit Breaker:** `client.circuitBreaker(toolName, options)(fn)` runs `fn`, after a workspace budget check when `requireBudget` is set, failing closed unless `failOpen` is set.
|
|
18
19
|
- **Context Resolution:** `resolveContext()` reads the sync daemon's `~/.intutic/config.json` (git branch, Jira ticket, PagerDuty incident, CI pipeline, workspace, session), falling back to environment variables.
|
|
19
|
-
- **
|
|
20
|
+
- **Git context (`autoContext`, on by default):** with an Intutic virtual key, in a git repository, the first `chat()` registers a session with the control plane carrying the repository (the `origin` remote as `host/path`, credentials removed), the branch and the HEAD commit, so the calls count in cost per branch, commit and pull request. Pass `autoContext: false` to send none of it. See [Git context and cost attribution](https://docs.intutic.ai/reference/clawde-sdk#_1a-git-context-and-cost-attribution).
|
|
21
|
+
- **Control-Plane Management (`ControlPlaneClient`):** org signup and creation, teams and workspaces, gateway registration, assignment and live config (`getGatewayConfig`, `setGatewayConfig`), workspace settings (`getWorkspaceSettings`, `updateWorkspaceSettings`) and provider credentials. See [Control-Plane Management](https://docs.intutic.ai/reference/clawde-sdk#control-plane-management-controlplaneclient).
|
|
20
22
|
|
|
21
23
|
## License
|
|
22
24
|
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ClawdeClientOptions, ChatParams, ChatResponse, ResolvedContext, BudgetCheckResult, EventCallback, CircuitBreakerOptions, VerdictEvent } from './types';
|
|
2
|
+
/** The harness a session this SDK registers is recorded under. */
|
|
3
|
+
export declare const SDK_HARNESS = "clawde_sdk";
|
|
2
4
|
export declare class ClawdeClient {
|
|
3
5
|
private apiKey;
|
|
4
6
|
private baseUrl;
|
|
@@ -12,6 +14,8 @@ export declare class ClawdeClient {
|
|
|
12
14
|
private budgetChecker;
|
|
13
15
|
private circuitBreakerWrapper;
|
|
14
16
|
private eventEmitter;
|
|
17
|
+
/** The session this client's requests are filed under, resolved once, on the first `chat()`. */
|
|
18
|
+
private session?;
|
|
15
19
|
constructor(options: ClawdeClientOptions);
|
|
16
20
|
on(event: VerdictEvent, callback: EventCallback): void;
|
|
17
21
|
off(event: string, callback: EventCallback): void;
|
|
@@ -23,10 +27,29 @@ export declare class ClawdeClient {
|
|
|
23
27
|
*
|
|
24
28
|
* Resolves with `verdict: 'allow'` when the proxy let the request through. A
|
|
25
29
|
* governance refusal, including one the proxy answers with a 200 and names in
|
|
26
|
-
* `x-intutic-refusal
|
|
27
|
-
* `ClawdeBlockedError`, unretried.
|
|
28
|
-
* answers are retried; anything else
|
|
30
|
+
* `x-intutic-refusal` (or, on a stream, in its `: intutic-refusal` line),
|
|
31
|
+
* fires the matching event and rejects with `ClawdeBlockedError`, unretried.
|
|
32
|
+
* Transport failures, timeouts and 5xx answers are retried; anything else
|
|
33
|
+
* rejects with `ClawdeConnectionError`.
|
|
29
34
|
*/
|
|
30
35
|
chat(params: ChatParams): Promise<ChatResponse>;
|
|
36
|
+
/**
|
|
37
|
+
* The session to send as `x-session-id`, or null to send none.
|
|
38
|
+
*
|
|
39
|
+
* A session id from the environment (`INTUTIC_SESSION_ID`, or the sync
|
|
40
|
+
* daemon's config) is the session that started this process, and its owner
|
|
41
|
+
* reports its context, so it is used as is. Otherwise, when the working
|
|
42
|
+
* directory is a git repository, this registers a session carrying its
|
|
43
|
+
* repository, branch and commit (`POST /api/v1/sessions`, as the sync
|
|
44
|
+
* daemon does), so cost per branch, commit and pull request includes this
|
|
45
|
+
* client's calls. Only with an Intutic virtual key: any other key is a
|
|
46
|
+
* provider's, and it is never sent to the control plane. `autoContext:
|
|
47
|
+
* false` turns this off. Best effort: a control plane that cannot be
|
|
48
|
+
* reached or refuses costs the attribution, never the call.
|
|
49
|
+
*/
|
|
50
|
+
private openSession;
|
|
51
|
+
private controlPlane;
|
|
52
|
+
/** Fires the refusal's event, then throws it. */
|
|
53
|
+
private refuse;
|
|
31
54
|
}
|
|
32
55
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,UAAU,EACV,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,YAAY,EACb,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,UAAU,EACV,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,YAAY,EACb,MAAM,SAAS,CAAA;AAWhB,kEAAkE;AAClE,eAAO,MAAM,WAAW,eAAe,CAAA;AAEvC,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,eAAe,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,CAAmC;IACpD,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,OAAO,CAAQ;IAEvB,wEAAwE;IACxE,OAAO,CAAC,QAAQ,CAAe;IAE/B,OAAO,CAAC,aAAa,CAAe;IACpC,OAAO,CAAC,qBAAqB,CAAgB;IAC7C,OAAO,CAAC,YAAY,CAAoB;IAExC,gGAAgG;IAChG,OAAO,CAAC,OAAO,CAAC,CAAwB;gBAE5B,OAAO,EAAE,mBAAmB;IAuBjC,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI;IAItD,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI;IAK3C,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAK/E,cAAc,IAAI,OAAO,CAAC,eAAe,CAAC;IAQhD,cAAc,CAAC,CAAC,EACrB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,qBAA0B,GAClC,CAAC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC;IAIvC;;;;;;;;;OASG;IACU,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC;IAsF5D;;;;;;;;;;;;;OAaG;YACW,WAAW;YA0BX,YAAY;IAW1B,iDAAiD;IACjD,OAAO,CAAC,MAAM;CAIf"}
|
package/dist/client.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ClawdeClient = void 0;
|
|
3
|
+
exports.ClawdeClient = exports.SDK_HARNESS = void 0;
|
|
4
4
|
const errors_1 = require("./errors");
|
|
5
5
|
const refusals_1 = require("./refusals");
|
|
6
6
|
const schema_enforcer_1 = require("./schema-enforcer");
|
|
7
7
|
const context_resolver_1 = require("./context-resolver");
|
|
8
|
+
const git_context_1 = require("./git-context");
|
|
8
9
|
const budget_checker_1 = require("./budget-checker");
|
|
9
10
|
const circuit_breaker_1 = require("./circuit-breaker");
|
|
10
11
|
const event_emitter_1 = require("./event-emitter");
|
|
11
12
|
const graph_identity_1 = require("./graph-identity");
|
|
13
|
+
/** The harness a session this SDK registers is recorded under. */
|
|
14
|
+
exports.SDK_HARNESS = 'clawde_sdk';
|
|
12
15
|
class ClawdeClient {
|
|
13
16
|
apiKey;
|
|
14
17
|
baseUrl;
|
|
@@ -22,6 +25,8 @@ class ClawdeClient {
|
|
|
22
25
|
budgetChecker;
|
|
23
26
|
circuitBreakerWrapper;
|
|
24
27
|
eventEmitter;
|
|
28
|
+
/** The session this client's requests are filed under, resolved once, on the first `chat()`. */
|
|
29
|
+
session;
|
|
25
30
|
constructor(options) {
|
|
26
31
|
if (!options.apiKey) {
|
|
27
32
|
throw new Error('API key is required to initialize ClawdeClient.');
|
|
@@ -68,11 +73,14 @@ class ClawdeClient {
|
|
|
68
73
|
*
|
|
69
74
|
* Resolves with `verdict: 'allow'` when the proxy let the request through. A
|
|
70
75
|
* governance refusal, including one the proxy answers with a 200 and names in
|
|
71
|
-
* `x-intutic-refusal
|
|
72
|
-
* `ClawdeBlockedError`, unretried.
|
|
73
|
-
* answers are retried; anything else
|
|
76
|
+
* `x-intutic-refusal` (or, on a stream, in its `: intutic-refusal` line),
|
|
77
|
+
* fires the matching event and rejects with `ClawdeBlockedError`, unretried.
|
|
78
|
+
* Transport failures, timeouts and 5xx answers are retried; anything else
|
|
79
|
+
* rejects with `ClawdeConnectionError`.
|
|
74
80
|
*/
|
|
75
81
|
async chat(params) {
|
|
82
|
+
this.session ??= this.openSession();
|
|
83
|
+
const sessionId = await this.session;
|
|
76
84
|
const anthropic = this.provider === 'anthropic';
|
|
77
85
|
// The proxy picks the wire format by route: an Anthropic Messages body
|
|
78
86
|
// sent to /v1/chat/completions is parsed as an OpenAI one.
|
|
@@ -86,6 +94,9 @@ class ClawdeClient {
|
|
|
86
94
|
// request as a graph of one, and skips membership, fleet spend and
|
|
87
95
|
// node counting entirely.
|
|
88
96
|
...(0, graph_identity_1.identityHeaders)(this.identity),
|
|
97
|
+
// The proxy files the trace under this session, and the control plane
|
|
98
|
+
// copies the session's repository, branch and commit onto it.
|
|
99
|
+
...(sessionId ? { 'x-session-id': sessionId } : {}),
|
|
89
100
|
};
|
|
90
101
|
const body = JSON.stringify((0, schema_enforcer_1.normalizeRequest)(params, this.provider));
|
|
91
102
|
let lastError = '';
|
|
@@ -102,10 +113,12 @@ class ClawdeClient {
|
|
|
102
113
|
let status;
|
|
103
114
|
let text;
|
|
104
115
|
let refusedBy;
|
|
116
|
+
let refusedRule;
|
|
105
117
|
try {
|
|
106
118
|
const response = await fetch(url, { method: 'POST', headers, body, signal: controller.signal });
|
|
107
119
|
status = response.status;
|
|
108
120
|
refusedBy = response.headers.get(refusals_1.REFUSAL_HEADER);
|
|
121
|
+
refusedRule = response.headers.get(refusals_1.REFUSAL_RULE_HEADER);
|
|
109
122
|
text = await response.text();
|
|
110
123
|
}
|
|
111
124
|
catch (err) {
|
|
@@ -121,24 +134,27 @@ class ClawdeClient {
|
|
|
121
134
|
json = JSON.parse(text);
|
|
122
135
|
}
|
|
123
136
|
catch {
|
|
137
|
+
// A `stream: true` request comes back as an event stream, which
|
|
138
|
+
// `chat()` does not parse; it still must not pass off a refusal
|
|
139
|
+
// the stream names as a transport failure.
|
|
140
|
+
const streamed = (0, refusals_1.streamRefusal)(text);
|
|
141
|
+
if (streamed)
|
|
142
|
+
this.refuse(streamed, status);
|
|
124
143
|
throw new errors_1.ClawdeConnectionError(`Proxy answered ${status} with a body that is not JSON: ${text}`);
|
|
125
144
|
}
|
|
126
145
|
const normalized = (0, schema_enforcer_1.normalizeResponse)(json, this.provider);
|
|
127
|
-
// A refusal answered as an assistant turn
|
|
146
|
+
// A refusal answered as an assistant turn: a withheld tool call, a
|
|
147
|
+
// withheld body, or the cost-prediction gate.
|
|
128
148
|
const content = normalized.choices?.[0]?.message?.content;
|
|
129
|
-
const answered = (0, refusals_1.headerRefusal)(refusedBy, typeof content === 'string' ? content : '');
|
|
130
|
-
if (answered)
|
|
131
|
-
this.
|
|
132
|
-
throw new errors_1.ClawdeBlockedError(answered.verdict, answered.code, status, answered.message);
|
|
133
|
-
}
|
|
149
|
+
const answered = (0, refusals_1.headerRefusal)(refusedBy, refusedRule, typeof content === 'string' ? content : '');
|
|
150
|
+
if (answered)
|
|
151
|
+
this.refuse(answered, status);
|
|
134
152
|
normalized.verdict = 'allow';
|
|
135
153
|
return normalized;
|
|
136
154
|
}
|
|
137
155
|
const refusal = (0, refusals_1.parseRefusal)(status, text);
|
|
138
|
-
if (refusal)
|
|
139
|
-
this.
|
|
140
|
-
throw new errors_1.ClawdeBlockedError(refusal.verdict, refusal.code, status, refusal.message);
|
|
141
|
-
}
|
|
156
|
+
if (refusal)
|
|
157
|
+
this.refuse(refusal, status);
|
|
142
158
|
lastError = `HTTP error ${status}: ${text}`;
|
|
143
159
|
// A 4xx that is not a refusal (bad key, malformed body) fails the same
|
|
144
160
|
// way every time; only a 5xx is worth another attempt.
|
|
@@ -147,6 +163,66 @@ class ClawdeClient {
|
|
|
147
163
|
}
|
|
148
164
|
throw new errors_1.ClawdeConnectionError(`Request failed after ${maxAttempts} attempts. Last error: ${lastError}`);
|
|
149
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* The session to send as `x-session-id`, or null to send none.
|
|
168
|
+
*
|
|
169
|
+
* A session id from the environment (`INTUTIC_SESSION_ID`, or the sync
|
|
170
|
+
* daemon's config) is the session that started this process, and its owner
|
|
171
|
+
* reports its context, so it is used as is. Otherwise, when the working
|
|
172
|
+
* directory is a git repository, this registers a session carrying its
|
|
173
|
+
* repository, branch and commit (`POST /api/v1/sessions`, as the sync
|
|
174
|
+
* daemon does), so cost per branch, commit and pull request includes this
|
|
175
|
+
* client's calls. Only with an Intutic virtual key: any other key is a
|
|
176
|
+
* provider's, and it is never sent to the control plane. `autoContext:
|
|
177
|
+
* false` turns this off. Best effort: a control plane that cannot be
|
|
178
|
+
* reached or refuses costs the attribution, never the call.
|
|
179
|
+
*/
|
|
180
|
+
async openSession() {
|
|
181
|
+
if (!this.autoContext)
|
|
182
|
+
return null;
|
|
183
|
+
const context = await (0, context_resolver_1.resolveContext)();
|
|
184
|
+
if (context.sessionId)
|
|
185
|
+
return context.sessionId;
|
|
186
|
+
if (!this.apiKey.startsWith('vk_'))
|
|
187
|
+
return null;
|
|
188
|
+
const git = await (0, git_context_1.resolveGitContext)(context.workingDirectory ?? process.cwd(), context.gitBranch);
|
|
189
|
+
if (Object.keys(git).length === 0)
|
|
190
|
+
return null;
|
|
191
|
+
try {
|
|
192
|
+
// whoami first, always: the repository goes only to a control plane
|
|
193
|
+
// that accepted the key. A workspace id from the environment proves
|
|
194
|
+
// nothing about the key, and the session route only takes the key's own.
|
|
195
|
+
const { workspaceId } = await this.controlPlane('GET', '/api/v1/auth/me');
|
|
196
|
+
const session = await this.controlPlane('POST', '/api/v1/sessions', {
|
|
197
|
+
workspaceId,
|
|
198
|
+
harnessType: exports.SDK_HARNESS,
|
|
199
|
+
...git,
|
|
200
|
+
});
|
|
201
|
+
return session.sessionId ?? null;
|
|
202
|
+
}
|
|
203
|
+
catch (err) {
|
|
204
|
+
if (process.env.INTUTIC_DEBUG === 'true') {
|
|
205
|
+
console.warn(`[Clawde SDK] No session registered; calls carry no git context: ${err instanceof Error ? err.message : String(err)}`);
|
|
206
|
+
}
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
async controlPlane(method, path, body) {
|
|
211
|
+
const res = await fetch(`${this.controlPlaneUrl}${path}`, {
|
|
212
|
+
method,
|
|
213
|
+
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${this.apiKey}` },
|
|
214
|
+
body: body === undefined ? undefined : JSON.stringify(body),
|
|
215
|
+
signal: AbortSignal.timeout(5_000),
|
|
216
|
+
});
|
|
217
|
+
if (!res.ok)
|
|
218
|
+
throw new Error(`${method} ${path} answered ${res.status}`);
|
|
219
|
+
return (await res.json());
|
|
220
|
+
}
|
|
221
|
+
/** Fires the refusal's event, then throws it. */
|
|
222
|
+
refuse(refusal, status) {
|
|
223
|
+
this.eventEmitter.emit(refusal.verdict, { ...refusal, status });
|
|
224
|
+
throw new errors_1.ClawdeBlockedError(refusal.verdict, refusal.code, status, refusal.message, refusal.ruleId);
|
|
225
|
+
}
|
|
150
226
|
}
|
|
151
227
|
exports.ClawdeClient = ClawdeClient;
|
|
152
228
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAUA,qCAAoE;AACpE,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAUA,qCAAoE;AACpE,yCAA+H;AAC/H,uDAAuE;AACvE,yDAAmD;AACnD,+CAAiD;AACjD,qDAAgD;AAChD,uDAAkD;AAClD,mDAAoD;AACpD,qDAAsF;AAEtF,kEAAkE;AACrD,QAAA,WAAW,GAAG,YAAY,CAAA;AAEvC,MAAa,YAAY;IACf,MAAM,CAAQ;IACd,OAAO,CAAQ;IACf,eAAe,CAAQ;IACvB,QAAQ,CAAoC;IAC5C,WAAW,CAAS;IACpB,OAAO,CAAQ;IACf,OAAO,CAAQ;IAEvB,wEAAwE;IAChE,QAAQ,CAAe;IAEvB,aAAa,CAAe;IAC5B,qBAAqB,CAAgB;IACrC,YAAY,CAAoB;IAExC,gGAAgG;IACxF,OAAO,CAAyB;IAExC,YAAY,OAA4B;QACtC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAA;QACpE,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAA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AAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,CAAC,CAAA;QAC/D,MAAM,IAAI,2BAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IACtG,CAAC;CACF;AA/ND,oCA+NC"}
|
package/dist/control-plane.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ControlPlaneClientOptions, WhoamiResult, OrgSignupParams, OrgSignupResult, StartDomainVerificationResult, CheckDomainVerificationResult, CreateOrgParams, CreateOrgResult, Team, Workspace, GatewayRegisterParams, GatewayRegisterResult, Gateway, GatewayRotateResult, GatewayStatus, GatewayConfigUpdate, GatewayConfigResult, GatewayResolution, ProviderCredentialStatus } from './types';
|
|
1
|
+
import type { ControlPlaneClientOptions, WhoamiResult, OrgSignupParams, OrgSignupResult, StartDomainVerificationResult, CheckDomainVerificationResult, CreateOrgParams, CreateOrgResult, Team, Workspace, GatewayRegisterParams, GatewayRegisterResult, Gateway, GatewayRotateResult, GatewayStatus, GatewayConfigUpdate, GatewayConfigResult, GatewayResolution, ProviderCredentialStatus, WorkspaceSettings, WorkspaceSettingsUpdateResult } from './types';
|
|
2
2
|
/**
|
|
3
|
-
* Control-plane management client
|
|
3
|
+
* Control-plane management client — org/team/gateway/credentials
|
|
4
4
|
* administration, as distinct from `ClawdeClient`'s data-plane chat calls.
|
|
5
5
|
*
|
|
6
6
|
* Deliberately a separate class, not new methods on `ClawdeClient`:
|
|
@@ -11,7 +11,7 @@ import type { ControlPlaneClientOptions, WhoamiResult, OrgSignupParams, OrgSignu
|
|
|
11
11
|
* on a class whose whole contract today is "one client, one proxy."
|
|
12
12
|
*
|
|
13
13
|
* Every endpoint here is mirrored 1:1 from `tools/cli/src/commands/{org,
|
|
14
|
-
* team,gateway,credentials,whoami}.ts` — the CLI's own already-tested
|
|
14
|
+
* team,gateway,credentials,settings,whoami}.ts` — the CLI's own already-tested
|
|
15
15
|
* contracts, not re-derived. Endpoints deliberately NOT included: session
|
|
16
16
|
* establishment (`login`/`logout` — an SDK caller supplies `apiKey`
|
|
17
17
|
* directly), and local-environment/terminal concerns (`init`, `doctor`,
|
|
@@ -91,6 +91,8 @@ export declare class ControlPlaneClient {
|
|
|
91
91
|
rotateGatewayToken(gatewayId: string): Promise<GatewayRotateResult>;
|
|
92
92
|
/** DELETE /api/v1/gateways/:id */
|
|
93
93
|
revokeGateway(gatewayId: string, reason?: string): Promise<void>;
|
|
94
|
+
/** GET /api/v1/gateways/:id/config — the flags set on the gateway and their version, as the gateway pulls them. */
|
|
95
|
+
getGatewayConfig(gatewayId: string): Promise<GatewayConfigResult>;
|
|
94
96
|
/** PATCH /api/v1/gateways/:id/config */
|
|
95
97
|
setGatewayConfig(gatewayId: string, config: GatewayConfigUpdate): Promise<GatewayConfigResult>;
|
|
96
98
|
/** PATCH /api/v1/workspace/gateway — pass null to clear the override. */
|
|
@@ -103,6 +105,20 @@ export declare class ControlPlaneClient {
|
|
|
103
105
|
}>;
|
|
104
106
|
/** GET /api/v1/workspace/gateway-resolution */
|
|
105
107
|
resolveGateway(): Promise<GatewayResolution>;
|
|
108
|
+
/** GET /api/v1/workspace/settings — every setting, resolved with its default. */
|
|
109
|
+
getWorkspaceSettings(): Promise<WorkspaceSettings>;
|
|
110
|
+
/**
|
|
111
|
+
* PUT /api/v1/workspace/settings — the route `intutic settings set` calls.
|
|
112
|
+
*
|
|
113
|
+
* Only the keys given change; the rest are kept (`featureFlags` merges one
|
|
114
|
+
* level deeper, so one flag does not switch the others off). The control
|
|
115
|
+
* plane is the authority on which keys exist and what each accepts: an
|
|
116
|
+
* unknown key or a bad value is refused with a 400 naming it, a setting the
|
|
117
|
+
* workspace's plan does not include (the group policy below Biz Org) with a
|
|
118
|
+
* 403 "Upgrade required", and a member below OWNER or ADMIN with a 403. Each
|
|
119
|
+
* refusal throws `ClawdeConnectionError` carrying the server's answer.
|
|
120
|
+
*/
|
|
121
|
+
updateWorkspaceSettings(settings: Record<string, unknown>): Promise<WorkspaceSettingsUpdateResult>;
|
|
106
122
|
/** GET /api/v1/workspace/provider-credentials */
|
|
107
123
|
listProviderCredentials(): Promise<ProviderCredentialStatus[]>;
|
|
108
124
|
/** PUT /api/v1/workspace/provider-credentials/:provider */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control-plane.d.ts","sourceRoot":"","sources":["../src/control-plane.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,yBAAyB,EACzB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,6BAA6B,EAC7B,6BAA6B,EAC7B,eAAe,EACf,eAAe,EACf,IAAI,EACJ,SAAS,EACT,qBAAqB,EACrB,qBAAqB,EACrB,OAAO,EACP,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"control-plane.d.ts","sourceRoot":"","sources":["../src/control-plane.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,yBAAyB,EACzB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,6BAA6B,EAC7B,6BAA6B,EAC7B,eAAe,EACf,eAAe,EACf,IAAI,EACJ,SAAS,EACT,qBAAqB,EACrB,qBAAqB,EACrB,OAAO,EACP,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,wBAAwB,EACxB,iBAAiB,EACjB,6BAA6B,EAC9B,MAAM,SAAS,CAAA;AAEhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,OAAO,CAAQ;gBAEX,OAAO,EAAE,yBAAyB;YAShC,OAAO;IAuBrB,0BAA0B;IACb,MAAM,IAAI,OAAO,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AAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAI9E,wCAAwC;IAC3B,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAI3G,yEAAyE;IAC5D,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAIpG,8EAA8E;IACjE,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAI7G,+CAA+C;IAClC,cAAc,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAIzD,iFAAiF;IACpE,oBAAoB,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAI/D;;;;;;;;;;OAUG;IACU,uBAAuB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,6BAA6B,CAAC;IAI/G,iDAAiD;IACpC,uBAAuB,IAAI,OAAO,CAAC,wBAAwB,EAAE,CAAC;IAQ3E,2DAA2D;IAC9C,qBAAqB,CAChC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,OAAO,CAAC,wBAAwB,CAAC;IAIpC,8DAA8D;IACjD,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGtE"}
|
package/dist/control-plane.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ControlPlaneClient = void 0;
|
|
4
4
|
const errors_1 = require("./errors");
|
|
5
5
|
/**
|
|
6
|
-
* Control-plane management client
|
|
6
|
+
* Control-plane management client — org/team/gateway/credentials
|
|
7
7
|
* administration, as distinct from `ClawdeClient`'s data-plane chat calls.
|
|
8
8
|
*
|
|
9
9
|
* Deliberately a separate class, not new methods on `ClawdeClient`:
|
|
@@ -14,7 +14,7 @@ const errors_1 = require("./errors");
|
|
|
14
14
|
* on a class whose whole contract today is "one client, one proxy."
|
|
15
15
|
*
|
|
16
16
|
* Every endpoint here is mirrored 1:1 from `tools/cli/src/commands/{org,
|
|
17
|
-
* team,gateway,credentials,whoami}.ts` — the CLI's own already-tested
|
|
17
|
+
* team,gateway,credentials,settings,whoami}.ts` — the CLI's own already-tested
|
|
18
18
|
* contracts, not re-derived. Endpoints deliberately NOT included: session
|
|
19
19
|
* establishment (`login`/`logout` — an SDK caller supplies `apiKey`
|
|
20
20
|
* directly), and local-environment/terminal concerns (`init`, `doctor`,
|
|
@@ -152,6 +152,10 @@ class ControlPlaneClient {
|
|
|
152
152
|
async revokeGateway(gatewayId, reason) {
|
|
153
153
|
await this.request('DELETE', `/api/v1/gateways/${encodeURIComponent(gatewayId)}`, { reason });
|
|
154
154
|
}
|
|
155
|
+
/** GET /api/v1/gateways/:id/config — the flags set on the gateway and their version, as the gateway pulls them. */
|
|
156
|
+
async getGatewayConfig(gatewayId) {
|
|
157
|
+
return this.request('GET', `/api/v1/gateways/${encodeURIComponent(gatewayId)}/config`);
|
|
158
|
+
}
|
|
155
159
|
/** PATCH /api/v1/gateways/:id/config */
|
|
156
160
|
async setGatewayConfig(gatewayId, config) {
|
|
157
161
|
return this.request('PATCH', `/api/v1/gateways/${encodeURIComponent(gatewayId)}/config`, config);
|
|
@@ -168,6 +172,24 @@ class ControlPlaneClient {
|
|
|
168
172
|
async resolveGateway() {
|
|
169
173
|
return this.request('GET', '/api/v1/workspace/gateway-resolution');
|
|
170
174
|
}
|
|
175
|
+
/** GET /api/v1/workspace/settings — every setting, resolved with its default. */
|
|
176
|
+
async getWorkspaceSettings() {
|
|
177
|
+
return this.request('GET', '/api/v1/workspace/settings');
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* PUT /api/v1/workspace/settings — the route `intutic settings set` calls.
|
|
181
|
+
*
|
|
182
|
+
* Only the keys given change; the rest are kept (`featureFlags` merges one
|
|
183
|
+
* level deeper, so one flag does not switch the others off). The control
|
|
184
|
+
* plane is the authority on which keys exist and what each accepts: an
|
|
185
|
+
* unknown key or a bad value is refused with a 400 naming it, a setting the
|
|
186
|
+
* workspace's plan does not include (the group policy below Biz Org) with a
|
|
187
|
+
* 403 "Upgrade required", and a member below OWNER or ADMIN with a 403. Each
|
|
188
|
+
* refusal throws `ClawdeConnectionError` carrying the server's answer.
|
|
189
|
+
*/
|
|
190
|
+
async updateWorkspaceSettings(settings) {
|
|
191
|
+
return this.request('PUT', '/api/v1/workspace/settings', settings);
|
|
192
|
+
}
|
|
171
193
|
/** GET /api/v1/workspace/provider-credentials */
|
|
172
194
|
async listProviderCredentials() {
|
|
173
195
|
const res = await this.request('GET', '/api/v1/workspace/provider-credentials');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control-plane.js","sourceRoot":"","sources":["../src/control-plane.ts"],"names":[],"mappings":";;;AAAA,qCAAgD;
|
|
1
|
+
{"version":3,"file":"control-plane.js","sourceRoot":"","sources":["../src/control-plane.ts"],"names":[],"mappings":";;;AAAA,qCAAgD;AAyBhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAa,kBAAkB;IACrB,MAAM,CAAQ;IACd,OAAO,CAAQ;IAEvB,YAAY,OAAkC;QAC5C,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAA;QAC1E,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;QAC5B,IAAI,CAAC,OAAO;YACV,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,wBAAwB,CAAA;IACxF,CAAC;IAEO,K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O,CAAC,KAAK,EAAE,0CAA0C,kBAAkB,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;IAC9G,CAAC;IAED,8DAA8D;IACvD,KAAK,CAAC,uBAAuB,CAAC,QAAgB;QACnD,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,0CAA0C,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IACxG,CAAC;CACF;AA3MD,gDA2MC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -16,13 +16,17 @@ export declare class ClawdeVerdictError extends ClawdeError {
|
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* The proxy refused the request: a policy block, a reask, a loop run held for
|
|
19
|
-
* review, a spend cap
|
|
20
|
-
*
|
|
19
|
+
* review, a spend cap, a DLP block, or a tool call the model made that the
|
|
20
|
+
* proxy withheld. Never retried — the same request would be refused again.
|
|
21
|
+
* `code` is the proxy's refusal code, `message` its reason, and `ruleId` the
|
|
22
|
+
* rule that decided, when the proxy names one (every refusal it answers with
|
|
23
|
+
* a 200 does).
|
|
21
24
|
*/
|
|
22
25
|
export declare class ClawdeBlockedError extends ClawdeVerdictError {
|
|
23
26
|
verdict: RefusalVerdict;
|
|
24
27
|
readonly code: string;
|
|
25
28
|
readonly status: number;
|
|
26
|
-
|
|
29
|
+
readonly ruleId: string | undefined;
|
|
30
|
+
constructor(verdict: RefusalVerdict, code: string, status: number, message: string, ruleId?: string);
|
|
27
31
|
}
|
|
28
32
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAI5B;AAED,uGAAuG;AACvG,qBAAa,qBAAsB,SAAQ,WAAW;gBACxC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,yBAA0B,SAAQ,WAAW;gBAC5C,OAAO,EAAE,MAAM;CAI5B;AAED,2HAA2H;AAC3H,qBAAa,kBAAmB,SAAQ,WAAW;IAC1C,OAAO,EAAE,MAAM,CAAA;gBAEV,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK7C;AAED
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAI5B;AAED,uGAAuG;AACvG,qBAAa,qBAAsB,SAAQ,WAAW;gBACxC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,yBAA0B,SAAQ,WAAW;gBAC5C,OAAO,EAAE,MAAM;CAI5B;AAED,2HAA2H;AAC3H,qBAAa,kBAAmB,SAAQ,WAAW;IAC1C,OAAO,EAAE,MAAM,CAAA;gBAEV,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK7C;AAED;;;;;;;GAOG;AACH,qBAAa,kBAAmB,SAAQ,kBAAkB;IACzC,OAAO,EAAE,cAAc,CAAA;IACtC,SAAgB,IAAI,EAAE,MAAM,CAAA;IAC5B,SAAgB,MAAM,EAAE,MAAM,CAAA;IAC9B,SAAgB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;gBAE9B,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAOpG"}
|
package/dist/errors.js
CHANGED
|
@@ -35,17 +35,22 @@ class ClawdeVerdictError extends ClawdeError {
|
|
|
35
35
|
exports.ClawdeVerdictError = ClawdeVerdictError;
|
|
36
36
|
/**
|
|
37
37
|
* The proxy refused the request: a policy block, a reask, a loop run held for
|
|
38
|
-
* review, a spend cap
|
|
39
|
-
*
|
|
38
|
+
* review, a spend cap, a DLP block, or a tool call the model made that the
|
|
39
|
+
* proxy withheld. Never retried — the same request would be refused again.
|
|
40
|
+
* `code` is the proxy's refusal code, `message` its reason, and `ruleId` the
|
|
41
|
+
* rule that decided, when the proxy names one (every refusal it answers with
|
|
42
|
+
* a 200 does).
|
|
40
43
|
*/
|
|
41
44
|
class ClawdeBlockedError extends ClawdeVerdictError {
|
|
42
45
|
code;
|
|
43
46
|
status;
|
|
44
|
-
|
|
47
|
+
ruleId;
|
|
48
|
+
constructor(verdict, code, status, message, ruleId) {
|
|
45
49
|
super(verdict, message);
|
|
46
50
|
this.name = 'ClawdeBlockedError';
|
|
47
51
|
this.code = code;
|
|
48
52
|
this.status = status;
|
|
53
|
+
this.ruleId = ruleId;
|
|
49
54
|
}
|
|
50
55
|
}
|
|
51
56
|
exports.ClawdeBlockedError = ClawdeBlockedError;
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAEA,MAAa,WAAY,SAAQ,KAAK;IACpC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,aAAa,CAAA;IAC3B,CAAC;CACF;AALD,kCAKC;AAED,uGAAuG;AACvG,MAAa,qBAAsB,SAAQ,WAAW;IACpD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAA;IACrC,CAAC;CACF;AALD,sDAKC;AAED,MAAa,yBAA0B,SAAQ,WAAW;IACxD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAA;IACzC,CAAC;CACF;AALD,8DAKC;AAED,2HAA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MAAe;QACjG,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACvB,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAA;QAChC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;CACF;AAbD,gDAaC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface GitContext {
|
|
2
|
+
/** The `origin` remote as `host/path`, never with credentials. */
|
|
3
|
+
repoUrl?: string;
|
|
4
|
+
branchName?: string;
|
|
5
|
+
commitHash?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A remote reduced to `host/path`: lower-cased host, no scheme, user, password,
|
|
9
|
+
* port, query, fragment or `.git` suffix; null for anything that is not a
|
|
10
|
+
* network remote. A copy of `normalizeGitRemote` in `@intutic/shared-types`
|
|
11
|
+
* (this package has no dependencies), held to the same vectors in
|
|
12
|
+
* `packages/shared-types/fixtures/git-remote-vectors.json`. Normalised here,
|
|
13
|
+
* before it leaves the machine: a CI checkout's remote embeds a token.
|
|
14
|
+
*/
|
|
15
|
+
export declare function normalizeGitRemote(remote: string): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* The git context of `cwd`, best effort: a directory that is not a
|
|
18
|
+
* repository, or a machine without git, gives an empty object.
|
|
19
|
+
*
|
|
20
|
+
* A detached HEAD names no branch. That is how CI checks out a pull request,
|
|
21
|
+
* so the branch then comes from `GITHUB_HEAD_REF` (GitHub Actions' pull
|
|
22
|
+
* request head branch), else `fallbackBranch` (`resolveContext().gitBranch`).
|
|
23
|
+
* Values the control plane's session route would refuse are left out rather
|
|
24
|
+
* than failing the registration.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveGitContext(cwd: string, fallbackBranch?: string): Promise<GitContext>;
|
|
27
|
+
//# sourceMappingURL=git-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-context.d.ts","sourceRoot":"","sources":["../src/git-context.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,UAAU;IACzB,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAKD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA4BhE;AA0BD;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAcjG"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeGitRemote = normalizeGitRemote;
|
|
4
|
+
exports.resolveGitContext = resolveGitContext;
|
|
5
|
+
/**
|
|
6
|
+
* The repository, branch and HEAD commit a process runs in: what cost per
|
|
7
|
+
* branch, per commit and per pull request is attributed by.
|
|
8
|
+
*
|
|
9
|
+
* The control plane copies a session's git context onto every trace it
|
|
10
|
+
* records under that session (`POST /api/v1/sessions` takes `repoUrl`,
|
|
11
|
+
* `branchName` and `commitHash`, the same fields the sync daemon reports), so
|
|
12
|
+
* this is what `ClawdeClient` registers its session with. Without it, SDK
|
|
13
|
+
* traffic is filed under "No git context".
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
const child_process_1 = require("child_process");
|
|
18
|
+
/** Schemes git can fetch over the network. `file:` and local paths are not repositories anyone else can name. */
|
|
19
|
+
const NETWORK_SCHEMES = new Set(['http:', 'https:', 'ssh:', 'git:', 'git+ssh:', 'ssh+git:']);
|
|
20
|
+
/**
|
|
21
|
+
* A remote reduced to `host/path`: lower-cased host, no scheme, user, password,
|
|
22
|
+
* port, query, fragment or `.git` suffix; null for anything that is not a
|
|
23
|
+
* network remote. A copy of `normalizeGitRemote` in `@intutic/shared-types`
|
|
24
|
+
* (this package has no dependencies), held to the same vectors in
|
|
25
|
+
* `packages/shared-types/fixtures/git-remote-vectors.json`. Normalised here,
|
|
26
|
+
* before it leaves the machine: a CI checkout's remote embeds a token.
|
|
27
|
+
*/
|
|
28
|
+
function normalizeGitRemote(remote) {
|
|
29
|
+
const raw = remote.trim();
|
|
30
|
+
if (!raw || raw.includes('\\') || /^[a-zA-Z]:\//.test(raw))
|
|
31
|
+
return null;
|
|
32
|
+
let host;
|
|
33
|
+
let path;
|
|
34
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(raw)) {
|
|
35
|
+
let url;
|
|
36
|
+
try {
|
|
37
|
+
url = new URL(raw);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
if (!NETWORK_SCHEMES.has(url.protocol))
|
|
43
|
+
return null;
|
|
44
|
+
host = url.hostname;
|
|
45
|
+
path = url.pathname;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
// scp-like: [user[:password]@]host:path. A colon after the first slash
|
|
49
|
+
// makes it a local path, which is how git itself tells them apart.
|
|
50
|
+
const scp = /^(?:[^@/]+@)?([^:/\s]+):([^\s]+)$/.exec(raw);
|
|
51
|
+
if (!scp)
|
|
52
|
+
return null;
|
|
53
|
+
host = scp[1];
|
|
54
|
+
path = cutAtQueryOrFragment(scp[2]);
|
|
55
|
+
}
|
|
56
|
+
path = trimSlashes(trimSlashes(path).replace(/\.git$/, ''));
|
|
57
|
+
if (!host || !path)
|
|
58
|
+
return null;
|
|
59
|
+
return `${host.toLowerCase()}/${path}`;
|
|
60
|
+
}
|
|
61
|
+
// String scans rather than regexes: a remote is input the developer controls,
|
|
62
|
+
// and `[?#].*$` / `\/+$` backtrack quadratically on long runs.
|
|
63
|
+
function cutAtQueryOrFragment(s) {
|
|
64
|
+
for (let i = 0; i < s.length; i++)
|
|
65
|
+
if (s[i] === '?' || s[i] === '#')
|
|
66
|
+
return s.slice(0, i);
|
|
67
|
+
return s;
|
|
68
|
+
}
|
|
69
|
+
function trimSlashes(s) {
|
|
70
|
+
let start = 0;
|
|
71
|
+
let end = s.length;
|
|
72
|
+
while (start < end && s[start] === '/')
|
|
73
|
+
start++;
|
|
74
|
+
while (end > start && s[end - 1] === '/')
|
|
75
|
+
end--;
|
|
76
|
+
return s.slice(start, end);
|
|
77
|
+
}
|
|
78
|
+
function git(cwd, ...args) {
|
|
79
|
+
return new Promise((resolve) => {
|
|
80
|
+
(0, child_process_1.execFile)('git', args, { cwd, timeout: 3_000 }, (err, stdout) => {
|
|
81
|
+
const out = err ? '' : String(stdout).trim();
|
|
82
|
+
resolve(out.length > 0 ? out : undefined);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The git context of `cwd`, best effort: a directory that is not a
|
|
88
|
+
* repository, or a machine without git, gives an empty object.
|
|
89
|
+
*
|
|
90
|
+
* A detached HEAD names no branch. That is how CI checks out a pull request,
|
|
91
|
+
* so the branch then comes from `GITHUB_HEAD_REF` (GitHub Actions' pull
|
|
92
|
+
* request head branch), else `fallbackBranch` (`resolveContext().gitBranch`).
|
|
93
|
+
* Values the control plane's session route would refuse are left out rather
|
|
94
|
+
* than failing the registration.
|
|
95
|
+
*/
|
|
96
|
+
async function resolveGitContext(cwd, fallbackBranch) {
|
|
97
|
+
const [remote, head, commit] = await Promise.all([
|
|
98
|
+
git(cwd, 'remote', 'get-url', 'origin'),
|
|
99
|
+
git(cwd, 'rev-parse', '--abbrev-ref', 'HEAD'),
|
|
100
|
+
git(cwd, 'rev-parse', 'HEAD'),
|
|
101
|
+
]);
|
|
102
|
+
const repoUrl = remote ? normalizeGitRemote(remote) : null;
|
|
103
|
+
const branchName = (head !== 'HEAD' ? head : undefined) || process.env.GITHUB_HEAD_REF || fallbackBranch;
|
|
104
|
+
const context = {};
|
|
105
|
+
if (repoUrl && repoUrl.length <= 512)
|
|
106
|
+
context.repoUrl = repoUrl;
|
|
107
|
+
if (branchName && branchName.length <= 256)
|
|
108
|
+
context.branchName = branchName;
|
|
109
|
+
// A SHA-1 object id; a SHA-256 repository's 64-character id does not fit the column.
|
|
110
|
+
if (commit && /^[0-9a-f]{40}$/.test(commit))
|
|
111
|
+
context.commitHash = commit;
|
|
112
|
+
return context;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=git-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-context.js","sourceRoot":"","sources":["../src/git-context.ts"],"names":[],"mappings":";;AAgCA,gDA4BC;AAoCD,8CAcC;AA9GD;;;;;;;;;;;GAWG;AACH,iDAAwC;AASxC,iHAAiH;AACjH,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAA;AAE5F;;;;;;;GAOG;AACH,SAAgB,kBAAkB,CAAC,MAAc;IAC/C,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,EAAE,CAAA;IACzB,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAA;IAEvE,IAAI,IAAY,CAAA;IAChB,IAAI,IAAY,CAAA;IAChB,IAAI,0BAA0B,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACzC,IAAI,GAAQ,CAAA;QACZ,IAAI,CAAC;YACH,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;QACpB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAA;QACb,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC;YA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AAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,cAAc,CAAA;IACxG,MAAM,OAAO,GAAe,EAAE,CAAA;IAC9B,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,IAAI,GAAG;QAAE,OAAO,CAAC,OAAO,GAAG,OAAO,CAAA;IAC/D,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,IAAI,GAAG;QAAE,OAAO,CAAC,UAAU,GAAG,UAAU,CAAA;IAC3E,qFAAqF;IACrF,IAAI,MAAM,IAAI,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO,CAAC,UAAU,GAAG,MAAM,CAAA;IACxE,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { ClawdeClient } from './client';
|
|
|
2
2
|
export { ControlPlaneClient } from './control-plane';
|
|
3
3
|
export * from './types';
|
|
4
4
|
export * from './errors';
|
|
5
|
+
export { PROXY_REFUSALS, REFUSAL_HEADER, REFUSAL_RULE_HEADER, STREAM_REFUSAL_MARKER, streamRefusal, type ProxyRefusal, } from './refusals';
|
|
5
6
|
export { resolveContext } from './context-resolver';
|
|
6
7
|
export { normalizeRequest, normalizeResponse } from './schema-enforcer';
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACpD,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACpD,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,OAAO,EACL,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EACrB,aAAa,EACb,KAAK,YAAY,GAClB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -14,13 +14,19 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.normalizeResponse = exports.normalizeRequest = exports.resolveContext = exports.ControlPlaneClient = exports.ClawdeClient = void 0;
|
|
17
|
+
exports.normalizeResponse = exports.normalizeRequest = exports.resolveContext = exports.streamRefusal = exports.STREAM_REFUSAL_MARKER = exports.REFUSAL_RULE_HEADER = exports.REFUSAL_HEADER = exports.PROXY_REFUSALS = exports.ControlPlaneClient = exports.ClawdeClient = void 0;
|
|
18
18
|
var client_1 = require("./client");
|
|
19
19
|
Object.defineProperty(exports, "ClawdeClient", { enumerable: true, get: function () { return client_1.ClawdeClient; } });
|
|
20
20
|
var control_plane_1 = require("./control-plane");
|
|
21
21
|
Object.defineProperty(exports, "ControlPlaneClient", { enumerable: true, get: function () { return control_plane_1.ControlPlaneClient; } });
|
|
22
22
|
__exportStar(require("./types"), exports);
|
|
23
23
|
__exportStar(require("./errors"), exports);
|
|
24
|
+
var refusals_1 = require("./refusals");
|
|
25
|
+
Object.defineProperty(exports, "PROXY_REFUSALS", { enumerable: true, get: function () { return refusals_1.PROXY_REFUSALS; } });
|
|
26
|
+
Object.defineProperty(exports, "REFUSAL_HEADER", { enumerable: true, get: function () { return refusals_1.REFUSAL_HEADER; } });
|
|
27
|
+
Object.defineProperty(exports, "REFUSAL_RULE_HEADER", { enumerable: true, get: function () { return refusals_1.REFUSAL_RULE_HEADER; } });
|
|
28
|
+
Object.defineProperty(exports, "STREAM_REFUSAL_MARKER", { enumerable: true, get: function () { return refusals_1.STREAM_REFUSAL_MARKER; } });
|
|
29
|
+
Object.defineProperty(exports, "streamRefusal", { enumerable: true, get: function () { return refusals_1.streamRefusal; } });
|
|
24
30
|
var context_resolver_1 = require("./context-resolver");
|
|
25
31
|
Object.defineProperty(exports, "resolveContext", { enumerable: true, get: function () { return context_resolver_1.resolveContext; } });
|
|
26
32
|
var schema_enforcer_1 = require("./schema-enforcer");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAAuC;AAA9B,sGAAA,YAAY,OAAA;AACrB,iDAAoD;AAA3C,mHAAA,kBAAkB,OAAA;AAC3B,0CAAuB;AACvB,2CAAwB;AACxB,uDAAmD;AAA1C,kHAAA,cAAc,OAAA;AACvB,qDAAuE;AAA9D,mHAAA,gBAAgB,OAAA;AAAE,oHAAA,iBAAiB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAAuC;AAA9B,sGAAA,YAAY,OAAA;AACrB,iDAAoD;AAA3C,mHAAA,kBAAkB,OAAA;AAC3B,0CAAuB;AACvB,2CAAwB;AACxB,uCAOmB;AANjB,0GAAA,cAAc,OAAA;AACd,0GAAA,cAAc,OAAA;AACd,+GAAA,mBAAmB,OAAA;AACnB,iHAAA,qBAAqB,OAAA;AACrB,yGAAA,aAAa,OAAA;AAGf,uDAAmD;AAA1C,kHAAA,cAAc,OAAA;AACvB,qDAAuE;AAA9D,mHAAA,gBAAgB,OAAA;AAAE,oHAAA,iBAAiB,OAAA"}
|
package/dist/refusals.d.ts
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import type { RefusalVerdict } from './types';
|
|
2
2
|
/**
|
|
3
|
-
* The proxy's governance refusals
|
|
4
|
-
*
|
|
5
|
-
* the status it always pairs that type with, and the verdict it represents.
|
|
3
|
+
* The proxy's governance refusals, by code, with the status the proxy sends
|
|
4
|
+
* each with and the verdict it represents.
|
|
6
5
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
6
|
+
* Most arrive as an error: the code is the `error.type` of the proxy's JSON
|
|
7
|
+
* error body (`{"error": {"type", "message"}}`, `json_error` in
|
|
8
|
+
* packages/proxy/src/proxy.rs). Matching on the status and the code together
|
|
9
|
+
* matters because the same statuses also carry errors that are not decisions:
|
|
10
|
+
* a provider's own 429 rate limit, a 403 for a key used against the wrong
|
|
11
|
+
* workspace, a 400 for a malformed body. Those are not refusals and must not
|
|
12
|
+
* be reported as one.
|
|
11
13
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
14
|
+
* The rest (status 200, and `COST_GATE_EXCEEDED` on a non-streaming request)
|
|
15
|
+
* arrive in band: an assistant turn explaining the refusal, named by
|
|
16
|
+
* `REFUSAL_HEADER`, or on a stream by the `STREAM_REFUSAL_MARKER` comment line.
|
|
17
|
+
*
|
|
18
|
+
* `__tests__/refusals.test.ts` holds this table to
|
|
19
|
+
* packages/shared-types/fixtures/refusal-codes.json, the one list the proxy
|
|
20
|
+
* and the Python SDK are held to as well, so a refusal the proxy adds or
|
|
21
|
+
* renames fails the build instead of silently turning back into an `allow` or
|
|
22
|
+
* a retried connection error.
|
|
15
23
|
*/
|
|
16
24
|
export declare const PROXY_REFUSALS: Readonly<Record<string, {
|
|
17
25
|
status: number;
|
|
@@ -21,16 +29,32 @@ export interface ProxyRefusal {
|
|
|
21
29
|
verdict: RefusalVerdict;
|
|
22
30
|
code: string;
|
|
23
31
|
message: string;
|
|
32
|
+
/** The rule that decided, for a refusal the proxy answered in band. */
|
|
33
|
+
ruleId?: string;
|
|
24
34
|
}
|
|
25
35
|
/** The refusal an error response carries, or `null` when it is any other kind of failure. */
|
|
26
36
|
export declare function parseRefusal(status: number, body: string): ProxyRefusal | null;
|
|
27
37
|
/**
|
|
28
|
-
* The
|
|
29
|
-
* answer: the
|
|
30
|
-
*
|
|
31
|
-
*
|
|
38
|
+
* The headers the proxy sets on a 200 that is a refusal in the shape of an
|
|
39
|
+
* answer: the response gate withheld a tool call the model made, output DLP
|
|
40
|
+
* withheld the body, or the cost-prediction gate answered instead of the
|
|
41
|
+
* model. The first names the refusal's code, the second the rule that decided.
|
|
32
42
|
*/
|
|
33
43
|
export declare const REFUSAL_HEADER = "x-intutic-refusal";
|
|
44
|
+
export declare const REFUSAL_RULE_HEADER = "x-intutic-refusal-rule";
|
|
34
45
|
/** The refusal a 2xx response names in `REFUSAL_HEADER`, or `null` for a real answer. */
|
|
35
|
-
export declare function headerRefusal(code: string | null, message: string): ProxyRefusal | null;
|
|
46
|
+
export declare function headerRefusal(code: string | null, ruleId: string | null, message: string): ProxyRefusal | null;
|
|
47
|
+
/**
|
|
48
|
+
* The prefix of the SSE comment line that names a refusal on a stream:
|
|
49
|
+
* `: intutic-refusal {"code", "rule", "message"}`. The response headers went
|
|
50
|
+
* out before the refusal happened, so a stream says it in band; every SSE
|
|
51
|
+
* parser skips comment lines, so clients that do not look for it are
|
|
52
|
+
* unaffected.
|
|
53
|
+
*/
|
|
54
|
+
export declare const STREAM_REFUSAL_MARKER = ": intutic-refusal ";
|
|
55
|
+
/**
|
|
56
|
+
* The refusal named anywhere in a stream's text, or `null` when there is
|
|
57
|
+
* none. Pass the whole body, or each line as it arrives.
|
|
58
|
+
*/
|
|
59
|
+
export declare function streamRefusal(text: string): ProxyRefusal | null;
|
|
36
60
|
//# sourceMappingURL=refusals.d.ts.map
|
package/dist/refusals.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refusals.d.ts","sourceRoot":"","sources":["../src/refusals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C
|
|
1
|
+
{"version":3,"file":"refusals.d.ts","sourceRoot":"","sources":["../src/refusals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,cAAc,CAAA;CAAE,CAAC,CAiBhG,CAAA;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,6FAA6F;AAC7F,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAe9E;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,sBAAsB,CAAA;AACjD,eAAO,MAAM,mBAAmB,2BAA2B,CAAA;AAE3D,yFAAyF;AACzF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAG9G;AAED;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,uBAAuB,CAAA;AAEzD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAiB/D"}
|
package/dist/refusals.js
CHANGED
|
@@ -1,32 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.REFUSAL_HEADER = exports.PROXY_REFUSALS = void 0;
|
|
3
|
+
exports.STREAM_REFUSAL_MARKER = exports.REFUSAL_RULE_HEADER = exports.REFUSAL_HEADER = exports.PROXY_REFUSALS = void 0;
|
|
4
4
|
exports.parseRefusal = parseRefusal;
|
|
5
5
|
exports.headerRefusal = headerRefusal;
|
|
6
|
+
exports.streamRefusal = streamRefusal;
|
|
6
7
|
/**
|
|
7
|
-
* The proxy's governance refusals
|
|
8
|
-
*
|
|
9
|
-
* the status it always pairs that type with, and the verdict it represents.
|
|
8
|
+
* The proxy's governance refusals, by code, with the status the proxy sends
|
|
9
|
+
* each with and the verdict it represents.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* Most arrive as an error: the code is the `error.type` of the proxy's JSON
|
|
12
|
+
* error body (`{"error": {"type", "message"}}`, `json_error` in
|
|
13
|
+
* packages/proxy/src/proxy.rs). Matching on the status and the code together
|
|
14
|
+
* matters because the same statuses also carry errors that are not decisions:
|
|
15
|
+
* a provider's own 429 rate limit, a 403 for a key used against the wrong
|
|
16
|
+
* workspace, a 400 for a malformed body. Those are not refusals and must not
|
|
17
|
+
* be reported as one.
|
|
15
18
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
+
* The rest (status 200, and `COST_GATE_EXCEEDED` on a non-streaming request)
|
|
20
|
+
* arrive in band: an assistant turn explaining the refusal, named by
|
|
21
|
+
* `REFUSAL_HEADER`, or on a stream by the `STREAM_REFUSAL_MARKER` comment line.
|
|
22
|
+
*
|
|
23
|
+
* `__tests__/refusals.test.ts` holds this table to
|
|
24
|
+
* packages/shared-types/fixtures/refusal-codes.json, the one list the proxy
|
|
25
|
+
* and the Python SDK are held to as well, so a refusal the proxy adds or
|
|
26
|
+
* renames fails the build instead of silently turning back into an `allow` or
|
|
27
|
+
* a retried connection error.
|
|
19
28
|
*/
|
|
20
29
|
exports.PROXY_REFUSALS = {
|
|
21
30
|
policy_denied: { status: 403, verdict: 'kill' },
|
|
22
31
|
model_not_allowed: { status: 403, verdict: 'kill' },
|
|
23
32
|
LOOP_RUN_TERMINATED: { status: 403, verdict: 'kill' },
|
|
24
33
|
LOOP_RUN_PENDING_REVIEW: { status: 403, verdict: 'hold' },
|
|
34
|
+
policy_held: { status: 403, verdict: 'hold' },
|
|
25
35
|
policy_reask: { status: 409, verdict: 'reask' },
|
|
36
|
+
GOVERNANCE_UNAVAILABLE: { status: 403, verdict: 'kill' },
|
|
26
37
|
BUDGET_EXCEEDED: { status: 429, verdict: 'kill' },
|
|
27
38
|
OVERAGE_HARD_CAP_EXCEEDED: { status: 429, verdict: 'kill' },
|
|
28
39
|
COST_GATE_EXCEEDED: { status: 402, verdict: 'kill' },
|
|
29
40
|
dlp_policy_violation: { status: 400, verdict: 'kill' },
|
|
41
|
+
TOOL_DENIED: { status: 200, verdict: 'kill' },
|
|
42
|
+
SSO_GROUP: { status: 200, verdict: 'kill' },
|
|
43
|
+
SQL_GUARD: { status: 200, verdict: 'kill' },
|
|
44
|
+
RESPONSE_UNPARSEABLE: { status: 200, verdict: 'kill' },
|
|
45
|
+
OUTPUT_DLP: { status: 200, verdict: 'kill' },
|
|
30
46
|
};
|
|
31
47
|
/** The refusal an error response carries, or `null` when it is any other kind of failure. */
|
|
32
48
|
function parseRefusal(status, body) {
|
|
@@ -49,21 +65,57 @@ function parseRefusal(status, body) {
|
|
|
49
65
|
};
|
|
50
66
|
}
|
|
51
67
|
/**
|
|
52
|
-
* The
|
|
53
|
-
* answer: the
|
|
54
|
-
*
|
|
55
|
-
*
|
|
68
|
+
* The headers the proxy sets on a 200 that is a refusal in the shape of an
|
|
69
|
+
* answer: the response gate withheld a tool call the model made, output DLP
|
|
70
|
+
* withheld the body, or the cost-prediction gate answered instead of the
|
|
71
|
+
* model. The first names the refusal's code, the second the rule that decided.
|
|
56
72
|
*/
|
|
57
73
|
exports.REFUSAL_HEADER = 'x-intutic-refusal';
|
|
74
|
+
exports.REFUSAL_RULE_HEADER = 'x-intutic-refusal-rule';
|
|
58
75
|
/** The refusal a 2xx response names in `REFUSAL_HEADER`, or `null` for a real answer. */
|
|
59
|
-
function headerRefusal(code, message) {
|
|
76
|
+
function headerRefusal(code, ruleId, message) {
|
|
60
77
|
if (!code)
|
|
61
78
|
return null;
|
|
79
|
+
return named(code, ruleId || undefined, message);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The prefix of the SSE comment line that names a refusal on a stream:
|
|
83
|
+
* `: intutic-refusal {"code", "rule", "message"}`. The response headers went
|
|
84
|
+
* out before the refusal happened, so a stream says it in band; every SSE
|
|
85
|
+
* parser skips comment lines, so clients that do not look for it are
|
|
86
|
+
* unaffected.
|
|
87
|
+
*/
|
|
88
|
+
exports.STREAM_REFUSAL_MARKER = ': intutic-refusal ';
|
|
89
|
+
/**
|
|
90
|
+
* The refusal named anywhere in a stream's text, or `null` when there is
|
|
91
|
+
* none. Pass the whole body, or each line as it arrives.
|
|
92
|
+
*/
|
|
93
|
+
function streamRefusal(text) {
|
|
94
|
+
for (const line of text.split('\n')) {
|
|
95
|
+
if (!line.startsWith(exports.STREAM_REFUSAL_MARKER))
|
|
96
|
+
continue;
|
|
97
|
+
let payload;
|
|
98
|
+
try {
|
|
99
|
+
payload = JSON.parse(line.slice(exports.STREAM_REFUSAL_MARKER.length));
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (typeof payload?.code !== 'string')
|
|
105
|
+
continue;
|
|
106
|
+
return named(payload.code, typeof payload.rule === 'string' ? payload.rule : undefined, typeof payload.message === 'string' ? payload.message : '');
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
function named(code, ruleId, message) {
|
|
111
|
+
// A code this SDK version does not know is still a refusal: the proxy only
|
|
112
|
+
// names a response it did not let through.
|
|
62
113
|
const known = exports.PROXY_REFUSALS[code];
|
|
63
114
|
return {
|
|
64
115
|
verdict: known?.verdict ?? 'kill',
|
|
65
116
|
code,
|
|
66
117
|
message: message || code,
|
|
118
|
+
...(ruleId ? { ruleId } : {}),
|
|
67
119
|
};
|
|
68
120
|
}
|
|
69
121
|
//# sourceMappingURL=refusals.js.map
|
package/dist/refusals.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refusals.js","sourceRoot":"","sources":["../src/refusals.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"refusals.js","sourceRoot":"","sources":["../src/refusals.ts"],"names":[],"mappings":";;;AAoDA,oCAeC;AAYD,sCAGC;AAeD,sCAiBC;AAhHD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACU,QAAA,cAAc,GAA0E;IACnG,aAAa,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE;IAC/C,iBAAiB,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE;IACnD,mBAAmB,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE;IACrD,uBAAuB,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE;IACzD,WAAW,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE;IAC7C,YAAY,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE;IAC/C,sBAAsB,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE;IACxD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A;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAS,KAAK,CAAC,IAAY,EAAE,MAA0B,EAAE,OAAe;IACtE,2EAA2E;IAC3E,2CAA2C;IAC3C,MAAM,KAAK,GAAG,sBAAc,CAAC,IAAI,CAAC,CAAA;IAClC,OAAO;QACL,OAAO,EAAE,KAAK,EAAE,OAAO,IAAI,MAAM;QACjC,IAAI;QACJ,OAAO,EAAE,OAAO,IAAI,IAAI;QACxB,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9B,CAAA;AACH,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -110,10 +110,12 @@ export interface BudgetCheckResult {
|
|
|
110
110
|
export type EventCallback = (data: {
|
|
111
111
|
/** One of the `RefusalVerdict` values; typed wider so listeners written against 2.0 compile. */
|
|
112
112
|
verdict: Verdict | LegacyVerdict;
|
|
113
|
-
/** The proxy's
|
|
113
|
+
/** The proxy's refusal code, e.g. `policy_denied`, `OVERAGE_HARD_CAP_EXCEEDED` or `TOOL_DENIED`. */
|
|
114
114
|
code: string;
|
|
115
115
|
status: number;
|
|
116
116
|
message: string;
|
|
117
|
+
/** The rule that decided, when the proxy names one. */
|
|
118
|
+
ruleId?: string;
|
|
117
119
|
/** @deprecated Never set. */
|
|
118
120
|
budgetRemainingUsd?: number;
|
|
119
121
|
/** @deprecated Never set. */
|
|
@@ -242,15 +244,28 @@ export interface GatewayStatus {
|
|
|
242
244
|
litellmReachable: boolean | null;
|
|
243
245
|
lastError: string | null;
|
|
244
246
|
reportedAt: string | null;
|
|
247
|
+
/** The config version the gateway reported running in its last heartbeat; null when unreachable or not reported. */
|
|
248
|
+
appliedConfigVersion: number | null;
|
|
249
|
+
/** The version the latest config change produced; 0 before any. The gateway pulls it on its next heartbeat. */
|
|
250
|
+
desiredConfigVersion: number;
|
|
245
251
|
}
|
|
246
252
|
export interface GatewayConfigUpdate {
|
|
247
253
|
requireVk?: boolean;
|
|
248
254
|
requireProvisionedKey?: boolean;
|
|
249
255
|
}
|
|
250
256
|
export interface GatewayConfigResult {
|
|
257
|
+
/** The flags set on the gateway (`requireVk`, `requireProvisionedKey`). One never set is absent: the gateway runs its deployment's own value. */
|
|
251
258
|
config: Record<string, unknown>;
|
|
252
259
|
configVersion: number;
|
|
253
260
|
}
|
|
261
|
+
export interface WorkspaceSettings {
|
|
262
|
+
workspaceId: string;
|
|
263
|
+
/** Every setting, resolved with its default. */
|
|
264
|
+
settings: Record<string, unknown>;
|
|
265
|
+
}
|
|
266
|
+
export interface WorkspaceSettingsUpdateResult extends WorkspaceSettings {
|
|
267
|
+
updated: true;
|
|
268
|
+
}
|
|
254
269
|
export interface GatewayResolution {
|
|
255
270
|
source: 'workspace' | 'org' | 'default';
|
|
256
271
|
gateway: {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,QAAQ,CAAA;IAC5C,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC,OAAO,kBAAkB,EAAE,aAAa,CAAC,CAAA;CAClE;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAA;IAC9C,OAAO,EAAE,MAAM,GAAG,GAAG,EAAE,CAAA;IACvB,IAAI,CAAC,EAAE,MAAM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