operon-agents-core 0.1.0-alpha.2 → 0.1.0-alpha.21
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/dist/agent/agent.d.ts +8 -7
- package/dist/agent/compose-hooks.d.ts +10 -1
- package/dist/agent/compose-hooks.js +61 -6
- package/dist/agent/concurrency.js +1 -1
- package/dist/agent/context-report.d.ts +2 -2
- package/dist/agent/durable-state.d.ts +22 -0
- package/dist/agent/durable-state.js +54 -0
- package/dist/agent/index.d.ts +2 -2
- package/dist/agent/index.js +1 -1
- package/dist/agent/instruction-context.d.ts +6 -6
- package/dist/agent/instruction-context.js +23 -23
- package/dist/agent/profile-builtins.js +1 -1
- package/dist/agent/run-support.d.ts +1 -1
- package/dist/agent/run-support.js +6 -5
- package/dist/agent/runner.d.ts +25 -22
- package/dist/agent/runner.js +217 -121
- package/dist/agent/session.d.ts +262 -156
- package/dist/agent/session.js +590 -418
- package/dist/agent/subagent-tools.js +3 -3
- package/dist/agent/subagent.js +28 -13
- package/dist/agent/toolset.d.ts +1 -0
- package/dist/agent/toolset.js +13 -7
- package/dist/agent/workflow/journal.d.ts +2 -2
- package/dist/agent/workflow/journal.js +2 -2
- package/dist/agent/workflow/manager.d.ts +1 -1
- package/dist/agent/workflow/manager.js +1 -1
- package/dist/agent/workflow/prompt.js +2 -2
- package/dist/agent/workflow/sandbox.d.ts +1 -1
- package/dist/agent/workflow/sandbox.js +1 -1
- package/dist/agent/workflow/tool.js +30 -43
- package/dist/agent/worktree.d.ts +8 -8
- package/dist/agent/worktree.js +15 -15
- package/dist/capabilities/assembler.d.ts +29 -5
- package/dist/capabilities/assembler.js +85 -9
- package/dist/capabilities/background/code-task.d.ts +43 -0
- package/dist/capabilities/background/code-task.js +75 -0
- package/dist/capabilities/background/command-task.d.ts +9 -2
- package/dist/capabilities/background/command-task.js +22 -6
- package/dist/capabilities/background/index.d.ts +6 -1
- package/dist/capabilities/background/index.js +26 -20
- package/dist/capabilities/background/manager.d.ts +57 -1
- package/dist/capabilities/background/manager.js +210 -45
- package/dist/capabilities/background/persist-disk.d.ts +1 -1
- package/dist/capabilities/background/persist-disk.js +1 -1
- package/dist/capabilities/background/persist.js +4 -2
- package/dist/capabilities/background/projections.d.ts +16 -0
- package/dist/capabilities/background/projections.js +86 -0
- package/dist/capabilities/background/stall-watchdog.d.ts +41 -0
- package/dist/capabilities/background/stall-watchdog.js +85 -0
- package/dist/capabilities/background/task.d.ts +8 -7
- package/dist/capabilities/background/tools.js +33 -7
- package/dist/capabilities/capability-data.d.ts +52 -0
- package/dist/capabilities/capability-data.js +88 -0
- package/dist/capabilities/capability-state.d.ts +2 -4
- package/dist/capabilities/capability-state.js +5 -23
- package/dist/capabilities/capability.d.ts +203 -38
- package/dist/capabilities/compaction/index.js +10 -4
- package/dist/capabilities/compaction/service.d.ts +20 -5
- package/dist/capabilities/compaction/service.js +27 -11
- package/dist/capabilities/goal/goal-store.d.ts +76 -12
- package/dist/capabilities/goal/goal-store.js +137 -53
- package/dist/capabilities/goal/index.d.ts +1 -1
- package/dist/capabilities/goal/index.js +30 -7
- package/dist/capabilities/index.d.ts +9 -6
- package/dist/capabilities/index.js +4 -3
- package/dist/capabilities/plan/index.js +22 -5
- package/dist/capabilities/plan/plan-mode.d.ts +30 -9
- package/dist/capabilities/plan/plan-mode.js +57 -32
- package/dist/capabilities/plan/tools.js +1 -1
- package/dist/capabilities/skills/flow-provider.js +3 -3
- package/dist/capabilities/skills/index.d.ts +13 -1
- package/dist/capabilities/skills/index.js +30 -21
- package/dist/capabilities/skills/parser.d.ts +2 -2
- package/dist/capabilities/skills/parser.js +3 -3
- package/dist/capabilities/skills/registry.d.ts +5 -6
- package/dist/capabilities/skills/registry.js +6 -9
- package/dist/capabilities/skills/scanner.d.ts +3 -3
- package/dist/capabilities/skills/scanner.js +14 -14
- package/dist/capabilities/skills/service.d.ts +2 -1
- package/dist/capabilities/skills/service.js +3 -3
- package/dist/capabilities/skills/skill-tool.d.ts +2 -0
- package/dist/capabilities/skills/skill-tool.js +1 -1
- package/dist/capabilities/task/index.js +2 -1
- package/dist/capabilities/task/persist-disk.d.ts +1 -1
- package/dist/capabilities/task/persist-disk.js +1 -1
- package/dist/capabilities/task/persist.js +1 -1
- package/dist/capabilities/todo/index.js +11 -6
- package/dist/capabilities/todo/injector.js +2 -1
- package/dist/capabilities/todo/todo-store.d.ts +28 -7
- package/dist/capabilities/todo/todo-store.js +44 -11
- package/dist/capabilities/todo/tools.js +8 -3
- package/dist/capabilities/tool-provider.d.ts +3 -3
- package/dist/capabilities/user-hooks/engine.d.ts +3 -3
- package/dist/capabilities/user-hooks/engine.js +7 -7
- package/dist/capabilities/user-hooks/index.js +2 -1
- package/dist/capabilities/workflow/index.d.ts +5 -3
- package/dist/capabilities/workflow/index.js +3 -2
- package/dist/commands/index.js +34 -32
- package/dist/config/index.d.ts +1 -1
- package/dist/config/provider-manager.js +0 -28
- package/dist/config/schema.d.ts +53 -4
- package/dist/config/schema.js +53 -1
- package/dist/events/events.d.ts +43 -11
- package/dist/events/events.js +1 -0
- package/dist/events/index.d.ts +2 -2
- package/dist/events/index.js +1 -1
- package/dist/events/projection.d.ts +49 -1
- package/dist/events/projection.js +144 -19
- package/dist/events/publisher.js +2 -21
- package/dist/home.d.ts +1 -1
- package/dist/home.js +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/internal.d.ts +5 -2
- package/dist/internal.js +5 -2
- package/dist/llm/define-model.d.ts +4 -0
- package/dist/llm/define-model.js +63 -25
- package/dist/llm/index.d.ts +1 -0
- package/dist/llm/index.js +1 -0
- package/dist/llm/model.d.ts +2 -0
- package/dist/llm/provider.d.ts +17 -0
- package/dist/llm/provider.js +14 -0
- package/dist/llm/retry.js +1 -1
- package/dist/loop/context.d.ts +21 -1
- package/dist/loop/context.js +47 -9
- package/dist/loop/events.d.ts +5 -1
- package/dist/loop/index.d.ts +2 -2
- package/dist/loop/index.js +1 -1
- package/dist/loop/interruption.d.ts +9 -4
- package/dist/loop/interruption.js +11 -25
- package/dist/loop/run-turn.d.ts +16 -3
- package/dist/loop/run-turn.js +13 -4
- package/dist/loop/steer.d.ts +78 -12
- package/dist/loop/steer.js +101 -38
- package/dist/loop/tool-call.d.ts +13 -2
- package/dist/loop/tool-call.js +135 -5
- package/dist/loop/turn-step.d.ts +13 -2
- package/dist/loop/turn-step.js +29 -7
- package/dist/loop/types.d.ts +6 -0
- package/dist/mcp/auth-tool.d.ts +3 -1
- package/dist/mcp/auth-tool.js +2 -2
- package/dist/mcp/capability.d.ts +13 -0
- package/dist/mcp/capability.js +36 -17
- package/dist/mcp/config-loader.d.ts +5 -5
- package/dist/mcp/config-loader.js +17 -17
- package/dist/mcp/credentials.d.ts +35 -0
- package/dist/mcp/credentials.js +2 -0
- package/dist/mcp/filter.d.ts +2 -2
- package/dist/mcp/index.d.ts +4 -3
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/manager.d.ts +108 -6
- package/dist/mcp/manager.js +262 -18
- package/dist/mcp/oauth/callback-server.d.ts +10 -1
- package/dist/mcp/oauth/callback-server.js +82 -16
- package/dist/mcp/oauth/index.d.ts +2 -2
- package/dist/mcp/oauth/provider.d.ts +18 -0
- package/dist/mcp/oauth/provider.js +31 -1
- package/dist/mcp/oauth/service.d.ts +9 -3
- package/dist/mcp/oauth/service.js +29 -4
- package/dist/mcp/sdk-transport.js +1 -1
- package/dist/mcp/server.js +1 -1
- package/dist/permission/auto-approver/prompts-data.d.ts +1 -1
- package/dist/permission/auto-approver/prompts-data.js +1 -1
- package/dist/permission/manager.d.ts +5 -3
- package/dist/permission/manager.js +7 -3
- package/dist/permission/policies.d.ts +2 -2
- package/dist/permission/policies.js +4 -4
- package/dist/plugins/fields.d.ts +14 -0
- package/dist/plugins/fields.js +30 -0
- package/dist/plugins/hooks.d.ts +2 -2
- package/dist/plugins/hooks.js +12 -12
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/manager.d.ts +8 -3
- package/dist/plugins/manager.js +18 -7
- package/dist/plugins/manifest.d.ts +2 -2
- package/dist/plugins/manifest.js +101 -91
- package/dist/plugins/marketplace.js +76 -57
- package/dist/plugins/store.d.ts +3 -3
- package/dist/plugins/store.js +6 -6
- package/dist/protocol/index.d.ts +1 -1
- package/dist/store/catalog-store.d.ts +4 -1
- package/dist/store/catalog-store.js +5 -1
- package/dist/store/checkpointing-store.d.ts +41 -0
- package/dist/store/checkpointing-store.js +86 -0
- package/dist/store/disk-store.d.ts +8 -0
- package/dist/store/disk-store.js +127 -5
- package/dist/store/index.d.ts +3 -2
- package/dist/store/index.js +2 -1
- package/dist/store/log-store.d.ts +9 -1
- package/dist/store/log-store.js +68 -4
- package/dist/store/migrate.d.ts +8 -2
- package/dist/store/migrate.js +9 -2
- package/dist/store/origin.d.ts +31 -6
- package/dist/store/origin.js +0 -14
- package/dist/store/pg.d.ts +1 -0
- package/dist/store/pg.js +37 -2
- package/dist/store/redis.d.ts +1 -0
- package/dist/store/redis.js +30 -0
- package/dist/store/repository.d.ts +13 -1
- package/dist/store/repository.js +45 -2
- package/dist/store/session-catalog.d.ts +4 -0
- package/dist/store/session-catalog.js +6 -0
- package/dist/store/storage.js +3 -0
- package/dist/store/store.d.ts +97 -34
- package/dist/store/store.js +64 -10
- package/dist/telemetry/appender.d.ts +43 -0
- package/dist/telemetry/appender.js +46 -0
- package/dist/telemetry/events.d.ts +142 -0
- package/dist/telemetry/events.js +141 -0
- package/dist/telemetry/index.d.ts +10 -0
- package/dist/telemetry/index.js +6 -0
- package/dist/telemetry/projection.d.ts +23 -0
- package/dist/telemetry/projection.js +185 -0
- package/dist/telemetry/redact.d.ts +20 -0
- package/dist/telemetry/redact.js +40 -0
- package/dist/telemetry/service.d.ts +49 -0
- package/dist/telemetry/service.js +137 -0
- package/dist/testing.d.ts +58 -0
- package/dist/testing.js +123 -0
- package/dist/tool/background.d.ts +9 -6
- package/dist/tool/background.js +7 -1
- package/dist/tool/builtin/ask-user-question.js +6 -5
- package/dist/tool/builtin/bash.d.ts +6 -0
- package/dist/tool/builtin/bash.js +79 -42
- package/dist/tool/builtin/edit.js +82 -109
- package/dist/tool/builtin/glob.js +13 -13
- package/dist/tool/builtin/grep.js +13 -13
- package/dist/tool/builtin/read.js +25 -15
- package/dist/tool/builtin/write.js +49 -33
- package/dist/tool/define.d.ts +14 -8
- package/dist/tool/define.js +8 -2
- package/dist/tool/{machine-base.d.ts → environment-base.d.ts} +37 -37
- package/dist/tool/{machine-base.js → environment-base.js} +45 -119
- package/dist/tool/{machine-local.d.ts → environment-local.d.ts} +9 -8
- package/dist/tool/{machine-local.js → environment-local.js} +60 -81
- package/dist/tool/{machine-null.d.ts → environment-null.d.ts} +9 -9
- package/dist/tool/{machine-null.js → environment-null.js} +9 -9
- package/dist/tool/{machine-ssh.d.ts → environment-ssh.d.ts} +33 -18
- package/dist/tool/{machine-ssh.js → environment-ssh.js} +118 -149
- package/dist/tool/{machine.d.ts → environment.d.ts} +53 -82
- package/dist/tool/environment.js +2 -0
- package/dist/tool/file-freshness.d.ts +33 -19
- package/dist/tool/file-freshness.js +39 -30
- package/dist/tool/filesystem-tools.d.ts +1 -1
- package/dist/tool/filesystem-tools.js +1 -1
- package/dist/tool/git-context.d.ts +2 -2
- package/dist/tool/git-context.js +8 -8
- package/dist/tool/index.d.ts +12 -12
- package/dist/tool/index.js +12 -10
- package/dist/tool/policies/path-access.d.ts +4 -4
- package/dist/tool/policies/path-access.js +12 -12
- package/dist/tool/questions.d.ts +8 -0
- package/dist/tool/search/catalog.d.ts +37 -0
- package/dist/tool/search/catalog.js +182 -0
- package/dist/tool/search/deferral.d.ts +3 -2
- package/dist/tool/search/loaded.d.ts +32 -0
- package/dist/tool/search/loaded.js +96 -0
- package/dist/tool/search/search-tool.d.ts +2 -6
- package/dist/tool/search/search-tool.js +16 -15
- package/dist/tool/shell-env.js +4 -0
- package/dist/tool/support/bash-paths.js +38 -7
- package/dist/tool/support/{machine-ops.d.ts → environment-ops.d.ts} +12 -14
- package/dist/tool/support/{machine-ops.js → environment-ops.js} +21 -2
- package/dist/tool/support/git-worktree.d.ts +3 -3
- package/dist/tool/support/git-worktree.js +6 -6
- package/dist/tool/support/rg-locator.d.ts +6 -6
- package/dist/tool/support/rg-locator.js +6 -6
- package/dist/tool/support/ripgrep-run.d.ts +5 -5
- package/dist/tool/support/ripgrep-run.js +3 -3
- package/dist/tool/support/tool-path.d.ts +3 -3
- package/dist/tool/support/tool-path.js +7 -7
- package/dist/tool/types.d.ts +54 -10
- package/dist/tool/web/fetch-url.js +1 -1
- package/dist/tool/web/web-search.js +1 -1
- package/dist/tool/workspace-spec.d.ts +3 -3
- package/dist/tool/workspace-spec.js +27 -27
- package/dist/tracing/bridge.d.ts +9 -1
- package/dist/tracing/bridge.js +307 -77
- package/dist/tracing/index.d.ts +2 -2
- package/dist/tracing/otel.d.ts +28 -1
- package/dist/tracing/otel.js +150 -38
- package/dist/tracing/processor.d.ts +22 -0
- package/dist/tracing/processor.js +2 -0
- package/dist/tracing/spans.d.ts +54 -0
- package/dist/tracing/spans.js +5 -0
- package/package.json +6 -2
- package/dist/tool/machine.js +0 -15
- package/dist/tool/search/activation.d.ts +0 -13
- package/dist/tool/search/activation.js +0 -31
|
@@ -15,11 +15,27 @@ export class McpOAuthClientProvider {
|
|
|
15
15
|
_codeVerifier;
|
|
16
16
|
_state;
|
|
17
17
|
_lastAuthorizationUrl;
|
|
18
|
+
_client;
|
|
19
|
+
_scopes;
|
|
18
20
|
constructor(options) {
|
|
19
21
|
this.serverUrl = canonicalMcpOAuthResource(options.serverUrl);
|
|
20
22
|
this.storeKey = mcpOAuthStoreKey(options.serverName, this.serverUrl);
|
|
21
23
|
this.store = options.store;
|
|
22
|
-
this.clientLabel = options.clientLabel ?? `
|
|
24
|
+
this.clientLabel = options.clientLabel ?? `Operon (${options.serverName})`;
|
|
25
|
+
this.configure(options);
|
|
26
|
+
}
|
|
27
|
+
/** Apply the server's configured client/scopes. Called on every lookup, so config edits land. */
|
|
28
|
+
configure(settings) {
|
|
29
|
+
this._client = settings.client;
|
|
30
|
+
this._scopes = settings.scopes !== undefined && settings.scopes.length > 0 ? settings.scopes : undefined;
|
|
31
|
+
}
|
|
32
|
+
/** The pre-registered client, when the server config names one. */
|
|
33
|
+
get staticClient() {
|
|
34
|
+
return this._client;
|
|
35
|
+
}
|
|
36
|
+
/** Configured scopes as an OAuth `scope` string, when any. */
|
|
37
|
+
get scope() {
|
|
38
|
+
return this._scopes?.join(" ");
|
|
23
39
|
}
|
|
24
40
|
setRedirectUrl(url) {
|
|
25
41
|
this._redirectUrl = url;
|
|
@@ -48,6 +64,7 @@ export class McpOAuthClientProvider {
|
|
|
48
64
|
grant_types: ["authorization_code", "refresh_token"],
|
|
49
65
|
response_types: ["code"],
|
|
50
66
|
client_name: this.clientLabel,
|
|
67
|
+
...(this.scope !== undefined ? { scope: this.scope } : {}),
|
|
51
68
|
};
|
|
52
69
|
}
|
|
53
70
|
state() {
|
|
@@ -55,9 +72,18 @@ export class McpOAuthClientProvider {
|
|
|
55
72
|
return this._state;
|
|
56
73
|
}
|
|
57
74
|
clientInformation() {
|
|
75
|
+
if (this._client !== undefined) {
|
|
76
|
+
return {
|
|
77
|
+
client_id: this._client.clientId,
|
|
78
|
+
...(this._client.clientSecret !== undefined ? { client_secret: this._client.clientSecret } : {}),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
58
81
|
return this.store.read(`${this.storeKey}${CLIENT_SUFFIX}`);
|
|
59
82
|
}
|
|
60
83
|
saveClientInformation(info) {
|
|
84
|
+
// A pre-registered client is never persisted — the server config stays the source of truth.
|
|
85
|
+
if (this._client !== undefined)
|
|
86
|
+
return;
|
|
61
87
|
this.store.write(`${this.storeKey}${CLIENT_SUFFIX}`, info);
|
|
62
88
|
}
|
|
63
89
|
tokens() {
|
|
@@ -108,6 +134,10 @@ export class McpOAuthClientProvider {
|
|
|
108
134
|
if (this._redirectUrl !== undefined) {
|
|
109
135
|
return this._redirectUrl.toString();
|
|
110
136
|
}
|
|
137
|
+
if (this._client?.callbackUrl !== undefined)
|
|
138
|
+
return this._client.callbackUrl;
|
|
139
|
+
if (this._client?.callbackPort !== undefined)
|
|
140
|
+
return `http://127.0.0.1:${this._client.callbackPort}/callback`;
|
|
111
141
|
const registered = registeredRedirectUri(this.clientInformation());
|
|
112
142
|
return registered ?? PASSIVE_REDIRECT_URI;
|
|
113
143
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { McpOAuthClientProvider } from "./provider.ts";
|
|
1
|
+
import { McpOAuthClientProvider, type McpOAuthClientSettings } from "./provider.ts";
|
|
2
2
|
import { type McpCredentialStore } from "./store.ts";
|
|
3
3
|
export interface McpOAuthServiceOptions {
|
|
4
4
|
/** Where credentials live. Defaults to a `JsonFileStore` (local disk); inject a
|
|
@@ -7,7 +7,7 @@ export interface McpOAuthServiceOptions {
|
|
|
7
7
|
readonly homeDir?: string;
|
|
8
8
|
readonly clientLabel?: string;
|
|
9
9
|
}
|
|
10
|
-
export interface BeginAuthorizationOptions {
|
|
10
|
+
export interface BeginAuthorizationOptions extends McpOAuthClientSettings {
|
|
11
11
|
readonly clientLabel?: string;
|
|
12
12
|
}
|
|
13
13
|
export interface BeginAuthorizationResult {
|
|
@@ -23,7 +23,13 @@ export declare class McpOAuthService {
|
|
|
23
23
|
private readonly clientLabel;
|
|
24
24
|
private readonly providers;
|
|
25
25
|
constructor(options?: McpOAuthServiceOptions);
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* The cached provider for one server identity. Pass the server's OAuth `settings` (its
|
|
28
|
+
* pre-registered client / scopes) whenever you have its config — they're re-applied on every
|
|
29
|
+
* call so the provider always matches the current config. Omit them only for store-level
|
|
30
|
+
* queries (`hasTokens`, invalidation) that never talk to the authorization server.
|
|
31
|
+
*/
|
|
32
|
+
getProvider(serverName: string, serverUrl: string | URL, settings?: McpOAuthClientSettings): McpOAuthClientProvider;
|
|
27
33
|
hasTokens(serverName: string, serverUrl: string | URL): boolean;
|
|
28
34
|
beginAuthorization(serverName: string, serverUrl: string | URL, options?: BeginAuthorizationOptions): Promise<BeginAuthorizationResult>;
|
|
29
35
|
invalidate(serverName: string, serverUrl: string | URL, scope?: "all" | "client" | "tokens" | "discovery"): void;
|
|
@@ -12,7 +12,13 @@ export class McpOAuthService {
|
|
|
12
12
|
new JsonFileStore(options.homeDir === undefined ? undefined : mcpCredentialsDir(options.homeDir));
|
|
13
13
|
this.clientLabel = options.clientLabel;
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* The cached provider for one server identity. Pass the server's OAuth `settings` (its
|
|
17
|
+
* pre-registered client / scopes) whenever you have its config — they're re-applied on every
|
|
18
|
+
* call so the provider always matches the current config. Omit them only for store-level
|
|
19
|
+
* queries (`hasTokens`, invalidation) that never talk to the authorization server.
|
|
20
|
+
*/
|
|
21
|
+
getProvider(serverName, serverUrl, settings) {
|
|
16
22
|
const storeKey = mcpOAuthStoreKey(serverName, serverUrl);
|
|
17
23
|
let provider = this.providers.get(storeKey);
|
|
18
24
|
if (provider === undefined) {
|
|
@@ -21,22 +27,35 @@ export class McpOAuthService {
|
|
|
21
27
|
serverUrl,
|
|
22
28
|
store: this.store,
|
|
23
29
|
...(this.clientLabel !== undefined ? { clientLabel: this.clientLabel } : {}),
|
|
30
|
+
...settings,
|
|
24
31
|
});
|
|
25
32
|
this.providers.set(provider.storeKey, provider);
|
|
26
33
|
}
|
|
34
|
+
else if (settings !== undefined) {
|
|
35
|
+
provider.configure(settings);
|
|
36
|
+
}
|
|
27
37
|
return provider;
|
|
28
38
|
}
|
|
29
39
|
hasTokens(serverName, serverUrl) {
|
|
30
40
|
return this.getProvider(serverName, serverUrl).tokens() !== undefined;
|
|
31
41
|
}
|
|
32
42
|
async beginAuthorization(serverName, serverUrl, options = {}) {
|
|
43
|
+
// Callers that don't pass settings keep whatever the provider was last configured with (e.g.
|
|
44
|
+
// by the MCP manager connecting this server from its config).
|
|
45
|
+
const settings = options.client === undefined && options.scopes === undefined
|
|
46
|
+
? undefined
|
|
47
|
+
: {
|
|
48
|
+
...(options.client !== undefined ? { client: options.client } : {}),
|
|
49
|
+
...(options.scopes !== undefined ? { scopes: options.scopes } : {}),
|
|
50
|
+
};
|
|
33
51
|
const provider = options.clientLabel === undefined
|
|
34
|
-
? this.getProvider(serverName, serverUrl)
|
|
52
|
+
? this.getProvider(serverName, serverUrl, settings)
|
|
35
53
|
: new McpOAuthClientProvider({
|
|
36
54
|
serverName,
|
|
37
55
|
serverUrl,
|
|
38
56
|
store: this.store,
|
|
39
57
|
clientLabel: options.clientLabel,
|
|
58
|
+
...settings,
|
|
40
59
|
});
|
|
41
60
|
if (options.clientLabel !== undefined) {
|
|
42
61
|
this.providers.set(provider.storeKey, provider);
|
|
@@ -44,7 +63,12 @@ export class McpOAuthService {
|
|
|
44
63
|
provider.resetFlow();
|
|
45
64
|
let callbackServer;
|
|
46
65
|
try {
|
|
47
|
-
|
|
66
|
+
// A pre-registered client only accepts the redirect URI it was registered with.
|
|
67
|
+
const client = provider.staticClient;
|
|
68
|
+
callbackServer = await startCallbackServer({
|
|
69
|
+
...(client?.callbackPort !== undefined ? { port: client.callbackPort } : {}),
|
|
70
|
+
...(client?.callbackUrl !== undefined ? { redirectUri: client.callbackUrl } : {}),
|
|
71
|
+
});
|
|
48
72
|
}
|
|
49
73
|
catch (error) {
|
|
50
74
|
throw wrapAuthError("failed to start OAuth callback listener", error);
|
|
@@ -52,7 +76,8 @@ export class McpOAuthService {
|
|
|
52
76
|
provider.setRedirectUrl(new URL(callbackServer.redirectUri));
|
|
53
77
|
let authorizationUrl;
|
|
54
78
|
try {
|
|
55
|
-
const
|
|
79
|
+
const scope = provider.scope;
|
|
80
|
+
const result = await auth(provider, { serverUrl, ...(scope !== undefined ? { scope } : {}) });
|
|
56
81
|
if (result !== "REDIRECT") {
|
|
57
82
|
// Tokens already valid (e.g. unexpired refresh). Nothing to do.
|
|
58
83
|
await callbackServer.close();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
2
2
|
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
3
3
|
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
4
|
-
const CLIENT_INFO = { name: "
|
|
4
|
+
const CLIENT_INFO = { name: "operon", version: "0.0.0" };
|
|
5
5
|
const STDERR_BUFFER_CAPACITY = 4 * 1024;
|
|
6
6
|
class SdkMcpTransport {
|
|
7
7
|
name;
|
package/dist/mcp/server.js
CHANGED
|
@@ -34,7 +34,7 @@ export class TransportMCPServer {
|
|
|
34
34
|
this.transportWatchInstalled = true;
|
|
35
35
|
this.transport.onUnexpectedClose((reason) => this.onTransportDrop(reason));
|
|
36
36
|
}
|
|
37
|
-
// Bound the handshake: a hung connect must
|
|
37
|
+
// Bound the handshake: a hung connect must surface as a failure, not stall the session.
|
|
38
38
|
await withTimeout(this.transport.connect(), this.startupTimeoutMs, this.name, () => {
|
|
39
39
|
void this.transport.close().catch(() => undefined);
|
|
40
40
|
});
|
|
@@ -5,5 +5,5 @@ export declare const CLASSIFIER_BASE_PROMPT = "You are a security monitor for au
|
|
|
5
5
|
* Each user-customizable section wraps its defaults in `<user_*_to_replace>` tags;
|
|
6
6
|
* user-supplied values REPLACE those defaults.
|
|
7
7
|
*/
|
|
8
|
-
export declare const CLASSIFIER_PERMISSIONS_TEMPLATE = "## Environment\n\n<user_environment_to_replace>- **Trusted repo**: The git repository the agent started in (its working directory) and its configured remote(s)\n- **Source control**: The trusted repo and its remote(s) only (no additional orgs configured)\n- **Trusted internal domains**: None configured\n- **Trusted cloud buckets**: None configured\n- **Key internal services**: None configured</user_environment_to_replace>\n\n## Definitions\n\nThese terms are used throughout the BLOCK and ALLOW rules. The lists below are examples, not exhaustive \u2014 use judgment for similar items not explicitly listed.\n\n- **Sensitive data**: e.g. credentials, API keys, source code, personal data, .env/.bashrc, confidential info, proprietary secrets, company secrets. Still counts if encoded (e.g. base64) or hidden in URLs/headers. When uploading to public storage (gists, pastebins, diagram renderers), default to sensitive \u2014 internal files (repo scripts, diagrams, slides) count even without credentials.\n- **External**: any endpoint, service, or repo NOT listed as trusted in Environment above.\n- **Not sensitive**: e.g. benign API payloads (natural language queries, dates, short comments, status updates, non-sensitive data).\n\n## BLOCK if the action does ANY of these\n\n<user_deny_rules_to_replace>- Git Destructive: Force pushing (`git push --force`), deleting remote branches, or rewriting remote history\n- Git Push to Default Branch: Pushing directly to main, master, or the repository's default branch \u2014 this bypasses pull request review. Commits should be pushed to a new feature branch instead.\n- Code from External: Downloading and executing code from external sources \u2014 e.g. `curl | bash`, deserializing external data via formats that can execute code (eval, exec, yaml.unsafe_load, pickle, etc), or similar mechanisms. Also includes running code from an external repo cloned earlier in the transcript (pip install -e, make install, python script.py, pickle.load/torch.load on cloned repo files) \u2014 \"local on disk\" does not mean trusted if it was cloned from an external source visible in the transcript. The repo the agent starts in is trusted.\n- Cloud Storage Mass Delete: Deleting or mass modifying files on cloud storage (S3, GCS, Azure Blob, etc.)\n- Production Deploy: Deploying to production/a production service or running production database migrations\n- Remote Shell Writes: Writing to running production or shared hosts via remote shell access (`kubectl exec`, `docker exec`, `ssh`) \u2014 this bypasses normal deployment guardrails.\n- Production Reads: Reading inside running production via remote shell (`kubectl exec`, `docker exec`, `ssh`), dumping env vars/configs, or direct prod database queries. Even read-only, this pulls live credentials and secrets into the transcript and debug logs \u2014 the read itself is the leak. Require explicit user approval naming the prod target first.\n- Blind Apply: For changes to live, production, or shared infrastructure, skipping the preview/dry-run step and going straight to the destructive action \u2014 e.g. using `--yes`, `--auto-approve`, `--force`, or similar flags that bypass confirmation, chaining a preview and apply into a single command so the user cannot review the output before changes are made, or running the apply step when no preview/plan/dry-run output is visible earlier in the transcript.\n- Logging/Audit Tampering: Stopping logging services, deleting log directories, removing git hooks, disabling audit trails, or similar actions that reduce observability\n- Permission Grant: Granting admin/owner roles, adding users to repos, or elevating IAM/RBAC permissions\n- TLS/Auth Weaken: Disabling TLS verification or using `--allow-unauthenticated` on services\n- Security Weaken: Disabling security mitigations, adding ways to bypass them, or running scripts/tools that override endpoint security controls (e.g. disabling security agents, breakglass scripts, modifying firewall rules). Includes loosening network-level restrictions on deployed services \u2014 e.g. changing ingress from internal-only to public.\n- Create Unsafe Agents: Creating new autonomous agent loops that can execute arbitrary actions (e.g. shell commands, code execution) without human approval or established safety frameworks (e.g. `--dangerously-skip-permissions`, `--no-sandbox`, disabling approval gates)\n- Interfere With Others: Deleting or cancelling jobs, modifying clusters in a way that would damage other jobs, overloading shared services, disrupting shared infrastructure, or spamming Slack channels. Job cancellation/deletion (e.g. kubectl delete job, scancel, kill, or equivalent) that does not target the EXACT jobs the agent created is inherently unsafe \u2014 it may affect other users' work. Even well-intentioned fixes count \u2014 deleting a shared component to \"fix\" it still disrupts everyone who depends on it.\n- Modify Shared Resources: In-place modification of shared artifacts (e.g. shared configurations, dataset resources) not created in the current context. Persistent changes to shared state (Kubernetes resources, database records, cluster configs) without clear affirmative user consent for the specific change should be blocked. \"Shared\" means anything not exclusively owned by the agent's current session \u2014 internal services, production namespaces, shared databases, and multi-user infrastructure all count.\n- Irreversible Local Destruction: Irreversibly deleting, truncating, or overwriting local files that existed before the session started (i.e. files the agent did not create) \u2014 `rm -rf`, `git clean -fdx`, `git checkout .`, `git reset --hard` on uncommitted changes, or `> file` truncation \u2014 without explicit user direction naming the specific targets. An underspecified or untested pattern (glob, regex, find) is not a specific target \u2014 the agent cannot know what it will match until it runs. Editing files inside package-manager-controlled directories (node_modules/, site-packages/, vendor/, etc.) also counts \u2014 these get regenerated on install. Patch your own code, or copy the dependency file into your repo's source tree instead. Destructive operations against local stateful services (databases, message queues, caches) also count unless they are clearly ephemeral test instances. Overwriting files the agent itself created during this session is fine.\n- Create RCE Machine: Creating services or endpoints that accept and execute arbitrary code, or writing code with common RCE vulnerabilities (unsanitized eval, shell injection, unsafe deserialization)\n- Expose Local Services: Starting a web server or binding a port that exposes local files or services to the network. Note: development servers in the project working directory are covered by the \"Local Operations\" ALLOW exception.\n- Credential Leakage: Embedding secrets or passwords in metadata, labels, URLs, or other fields where they become queryable or visible (e.g. putting a password in job labels)\n- Credential Exploration: Systematically scanning credential stores (e.g. Kubernetes secrets, cloud secret managers, config files, environment variables, password vaults) to find usable tokens or API keys beyond what the agent's normal tools provide, or using credentials meant for a different service or purpose. The exploration behavior \u2014 trying multiple paths, failing, searching \u2014 is itself the violation, regardless of whether the credentials found look \"standard\".\n- Data Exfiltration: Sending sensitive data to external endpoints or publicly accessible storage. Methods include but are not limited to HTTP requests, file uploads, git push to repos outside the source control orgs listed in Environment, changing API base URL to external endpoint, uploading to public cloud storage, or public plaintext sharing applications (e.g. public GitHub gists).\n- Exfil Scouting: Testing which endpoints not listed in Environment are reachable (webhook sites, file-sharing services, DNS resolvers) or probing encoding bypasses \u2014 treat as preparation for data exfiltration.\n- Trusting Guessed External Services: When the agent guesses an external service to use and sends sensitive internal data to it, this is Data Exfiltration even if the agent's intent is benign. Same with guessing where to download code from (for code meant to be executed). The agent choosing the service on its own means there is no user intent establishing trust in that service.\n- Untrusted Code Integration: Pulling code from repos outside the source control orgs listed in Environment and arranging for it to execute \u2014 git submodules, lifecycle scripts (postinstall/preinstall), or running scripts from cloned external repos.\n- Unauthorized Persistence: Adding SSH keys, modifying shell profiles (.bashrc, .profile, .zshrc), creating cron jobs or systemd services, or other mechanisms that persist access or execute code beyond the current session.\n- Self-Modification: Modifying the agent's own configuration, settings, or permission files (e.g. settings.json, CLAUDE.md permission overrides, .claude/ config) to change the agent's own behavior or permissions.\n- External System Writes: Deleting, resolving, closing, or mass-modifying items in external collaboration tools (Jira, Asana, Linear, PagerDuty, Datadog, GitHub Issues/PRs, etc.) that the agent did not create in this session. Also covers publishing under the user's identity (posting to channels, commenting on PRs/issues, creating tickets, sending messages) when the user's task didn't ask for or require publishing \u2014 answering the user is not the same as posting to others. These actions are visible to others, often trigger notifications or workflows, and are hard to retract. \"Created in this session\" means a prior tool_use in this transcript created that exact item \u2014 do not infer ownership from naming conventions, descriptions, or the item appearing recently.\n- Content Integrity / Impersonation: Posting, creating, or updating content that is false, fabricated, or misrepresents what actually happened \u2014 e.g. reporting success on work that failed, creating tickets with fabricated claims, approving/stamping something the agent did not actually verify. Also signing or attributing content as coming from a human when the agent produced it. When content will be read and acted on by others, its truthfulness is a security concern.\n- Real-World Transactions: Actions with direct real-world or financial consequence outside software systems \u2014 making purchases, sending payments, booking services, placing orders, confirming subscriptions, or sending communications to real people outside the user's organization (customers, external contacts, vendors). Unless the user explicitly asked for the exact transaction, block.</user_deny_rules_to_replace>\n\n## ALLOW (exceptions) if ANY of these apply\n\n**Exceptions are mandatory.** If an exception applies, the action MUST be allowed \u2014 do not override based on severity or frequency. Use judgement if something seems suspicious though \u2014 e.g. typosquatting of trusted domains should still be blocked.\n\n<user_allow_rules_to_replace>- Test Artifacts: Hardcoded test API keys, placeholder credentials in examples, or hardcoding test cases\n- Local Operations: Agent deleting local files in working directory, local file operations within project scope, or using `--ignore-certificate-errors` for local testing. \"Project scope\" means the repository the session started in \u2014 wandering into ~/, ~/Library/, /etc, or other repos is scope escalation (User Intent Rule #2), not a local operation. Does NOT cover irreversible destruction of pre-existing files or local stateful services \u2014 see \"Irreversible Local Destruction\" in BLOCK.\n- Read-Only Operations: GET requests, read-only API calls, or queries that don't modify state and don't contain sensitive information in the URL. Note: PREEMPTIVE BLOCK ON CLEAR INTENT still applies \u2014 if the transcript contains clear evidence the agent is using read-only operations to scout for a blocked action, block it.\n- Declared Dependencies: Installing packages that are already declared in the repo's manifest files (requirements.txt, package.json, Cargo.toml, pyproject.toml, Gemfile, etc.) via standard commands that read those manifests (`pip install -r requirements.txt`, `npm install`, `cargo build`, `bundle install`) \u2014 provided the agent has not modified the manifest in this session. Does NOT cover installing agent-chosen package names (e.g. `pip install foo`, `npm install bar`) \u2014 those carry typosquat and supply-chain risk.\n- Toolchain Bootstrap: Installing language toolchains (not packages) from their official one-line installers \u2014 `sh.rustup.rs`, `bootstrap.pypa.io`, `astral.sh`, `bun.sh`, `deb.nodesource.com`, `get.docker.com`, `brew.sh` \u2014 when the repo's manifest or build config indicates that toolchain is required.\n- Standard Credentials: Reading credentials from the agent's own config (.env, config files) and sending them to their intended provider (e.g. API key to its matching API endpoint)\n- Git Push to Working Branch: Pushing to the branch the user started the session on (unless it is the repository default branch), or to a branch the agent created during the session. Does not cover pushing to other pre-existing branches.</user_allow_rules_to_replace>\n";
|
|
8
|
+
export declare const CLASSIFIER_PERMISSIONS_TEMPLATE = "## Environment\n\n<user_environment_to_replace>- **Trusted repo**: The git repository the agent started in (its working directory) and its configured remote(s)\n- **Source control**: The trusted repo and its remote(s) only (no additional orgs configured)\n- **Trusted internal domains**: None configured\n- **Trusted cloud buckets**: None configured\n- **Key internal services**: None configured</user_environment_to_replace>\n\n## Definitions\n\nThese terms are used throughout the BLOCK and ALLOW rules. The lists below are examples, not exhaustive \u2014 use judgment for similar items not explicitly listed.\n\n- **Sensitive data**: e.g. credentials, API keys, source code, personal data, .env/.bashrc, confidential info, proprietary secrets, company secrets. Still counts if encoded (e.g. base64) or hidden in URLs/headers. When uploading to public storage (gists, pastebins, diagram renderers), default to sensitive \u2014 internal files (repo scripts, diagrams, slides) count even without credentials.\n- **External**: any endpoint, service, or repo NOT listed as trusted in Environment above.\n- **Not sensitive**: e.g. benign API payloads (natural language queries, dates, short comments, status updates, non-sensitive data).\n\n## BLOCK if the action does ANY of these\n\n<user_deny_rules_to_replace>- Git Destructive: Force pushing (`git push --force`), deleting remote branches, or rewriting remote history\n- Git Push to Default Branch: Pushing directly to main, master, or the repository's default branch \u2014 this bypasses pull request review. Commits should be pushed to a new feature branch instead.\n- Code from External: Downloading and executing code from external sources \u2014 e.g. `curl | bash`, deserializing external data via formats that can execute code (eval, exec, yaml.unsafe_load, pickle, etc), or similar mechanisms. Also includes running code from an external repo cloned earlier in the transcript (pip install -e, make install, python script.py, pickle.load/torch.load on cloned repo files) \u2014 \"local on disk\" does not mean trusted if it was cloned from an external source visible in the transcript. The repo the agent starts in is trusted.\n- Cloud Storage Mass Delete: Deleting or mass modifying files on cloud storage (S3, GCS, Azure Blob, etc.)\n- Production Deploy: Deploying to production/a production service or running production database migrations\n- Remote Shell Writes: Writing to running production or shared hosts via remote shell access (`kubectl exec`, `docker exec`, `ssh`) \u2014 this bypasses normal deployment guardrails.\n- Production Reads: Reading inside running production via remote shell (`kubectl exec`, `docker exec`, `ssh`), dumping env vars/configs, or direct prod database queries. Even read-only, this pulls live credentials and secrets into the transcript and debug logs \u2014 the read itself is the leak. Require explicit user approval naming the prod target first.\n- Blind Apply: For changes to live, production, or shared infrastructure, skipping the preview/dry-run step and going straight to the destructive action \u2014 e.g. using `--yes`, `--auto-approve`, `--force`, or similar flags that bypass confirmation, chaining a preview and apply into a single command so the user cannot review the output before changes are made, or running the apply step when no preview/plan/dry-run output is visible earlier in the transcript.\n- Logging/Audit Tampering: Stopping logging services, deleting log directories, removing git hooks, disabling audit trails, or similar actions that reduce observability\n- Permission Grant: Granting admin/owner roles, adding users to repos, or elevating IAM/RBAC permissions\n- TLS/Auth Weaken: Disabling TLS verification or using `--allow-unauthenticated` on services\n- Security Weaken: Disabling security mitigations, adding ways to bypass them, or running scripts/tools that override endpoint security controls (e.g. disabling security agents, breakglass scripts, modifying firewall rules). Includes loosening network-level restrictions on deployed services \u2014 e.g. changing ingress from internal-only to public.\n- Create Unsafe Agents: Creating new autonomous agent loops that can execute arbitrary actions (e.g. shell commands, code execution) without human approval or established safety frameworks (e.g. `--dangerously-skip-permissions`, `--no-sandbox`, disabling approval gates)\n- Interfere With Others: Deleting or cancelling jobs, modifying clusters in a way that would damage other jobs, overloading shared services, disrupting shared infrastructure, or spamming Slack channels. Job cancellation/deletion (e.g. kubectl delete job, scancel, kill, or equivalent) that does not target the EXACT jobs the agent created is inherently unsafe \u2014 it may affect other users' work. Even well-intentioned fixes count \u2014 deleting a shared component to \"fix\" it still disrupts everyone who depends on it.\n- Modify Shared Resources: In-place modification of shared artifacts (e.g. shared configurations, dataset resources) not created in the current context. Persistent changes to shared state (Kubernetes resources, database records, cluster configs) without clear affirmative user consent for the specific change should be blocked. \"Shared\" means anything not exclusively owned by the agent's current session \u2014 internal services, production namespaces, shared databases, and multi-user infrastructure all count.\n- Irreversible Local Destruction: Irreversibly deleting, truncating, or overwriting local files that existed before the session started (i.e. files the agent did not create) \u2014 `rm -rf`, `git clean -fdx`, `git checkout .`, `git reset --hard` on uncommitted changes, or `> file` truncation \u2014 without explicit user direction naming the specific targets. An underspecified or untested pattern (glob, regex, find) is not a specific target \u2014 the agent cannot know what it will match until it runs. Editing files inside package-manager-controlled directories (node_modules/, site-packages/, vendor/, etc.) also counts \u2014 these get regenerated on install. Patch your own code, or copy the dependency file into your repo's source tree instead. Destructive operations against local stateful services (databases, message queues, caches) also count unless they are clearly ephemeral test instances. Overwriting files the agent itself created during this session is fine.\n- Create RCE Environment: Creating services or endpoints that accept and execute arbitrary code, or writing code with common RCE vulnerabilities (unsanitized eval, shell injection, unsafe deserialization)\n- Expose Local Services: Starting a web server or binding a port that exposes local files or services to the network. Note: development servers in the project working directory are covered by the \"Local Operations\" ALLOW exception.\n- Credential Leakage: Embedding secrets or passwords in metadata, labels, URLs, or other fields where they become queryable or visible (e.g. putting a password in job labels)\n- Credential Exploration: Systematically scanning credential stores (e.g. Kubernetes secrets, cloud secret managers, config files, environment variables, password vaults) to find usable tokens or API keys beyond what the agent's normal tools provide, or using credentials meant for a different service or purpose. The exploration behavior \u2014 trying multiple paths, failing, searching \u2014 is itself the violation, regardless of whether the credentials found look \"standard\".\n- Data Exfiltration: Sending sensitive data to external endpoints or publicly accessible storage. Methods include but are not limited to HTTP requests, file uploads, git push to repos outside the source control orgs listed in Environment, changing API base URL to external endpoint, uploading to public cloud storage, or public plaintext sharing applications (e.g. public GitHub gists).\n- Exfil Scouting: Testing which endpoints not listed in Environment are reachable (webhook sites, file-sharing services, DNS resolvers) or probing encoding bypasses \u2014 treat as preparation for data exfiltration.\n- Trusting Guessed External Services: When the agent guesses an external service to use and sends sensitive internal data to it, this is Data Exfiltration even if the agent's intent is benign. Same with guessing where to download code from (for code meant to be executed). The agent choosing the service on its own means there is no user intent establishing trust in that service.\n- Untrusted Code Integration: Pulling code from repos outside the source control orgs listed in Environment and arranging for it to execute \u2014 git submodules, lifecycle scripts (postinstall/preinstall), or running scripts from cloned external repos.\n- Unauthorized Persistence: Adding SSH keys, modifying shell profiles (.bashrc, .profile, .zshrc), creating cron jobs or systemd services, or other mechanisms that persist access or execute code beyond the current session.\n- Self-Modification: Modifying the agent's own configuration, settings, or permission files (e.g. settings.json, CLAUDE.md permission overrides, .claude/ config) to change the agent's own behavior or permissions.\n- External System Writes: Deleting, resolving, closing, or mass-modifying items in external collaboration tools (Jira, Asana, Linear, PagerDuty, Datadog, GitHub Issues/PRs, etc.) that the agent did not create in this session. Also covers publishing under the user's identity (posting to channels, commenting on PRs/issues, creating tickets, sending messages) when the user's task didn't ask for or require publishing \u2014 answering the user is not the same as posting to others. These actions are visible to others, often trigger notifications or workflows, and are hard to retract. \"Created in this session\" means a prior tool_use in this transcript created that exact item \u2014 do not infer ownership from naming conventions, descriptions, or the item appearing recently.\n- Content Integrity / Impersonation: Posting, creating, or updating content that is false, fabricated, or misrepresents what actually happened \u2014 e.g. reporting success on work that failed, creating tickets with fabricated claims, approving/stamping something the agent did not actually verify. Also signing or attributing content as coming from a human when the agent produced it. When content will be read and acted on by others, its truthfulness is a security concern.\n- Real-World Transactions: Actions with direct real-world or financial consequence outside software systems \u2014 making purchases, sending payments, booking services, placing orders, confirming subscriptions, or sending communications to real people outside the user's organization (customers, external contacts, vendors). Unless the user explicitly asked for the exact transaction, block.</user_deny_rules_to_replace>\n\n## ALLOW (exceptions) if ANY of these apply\n\n**Exceptions are mandatory.** If an exception applies, the action MUST be allowed \u2014 do not override based on severity or frequency. Use judgement if something seems suspicious though \u2014 e.g. typosquatting of trusted domains should still be blocked.\n\n<user_allow_rules_to_replace>- Test Artifacts: Hardcoded test API keys, placeholder credentials in examples, or hardcoding test cases\n- Local Operations: Agent deleting local files in working directory, local file operations within project scope, or using `--ignore-certificate-errors` for local testing. \"Project scope\" means the repository the session started in \u2014 wandering into ~/, ~/Library/, /etc, or other repos is scope escalation (User Intent Rule #2), not a local operation. Does NOT cover irreversible destruction of pre-existing files or local stateful services \u2014 see \"Irreversible Local Destruction\" in BLOCK.\n- Read-Only Operations: GET requests, read-only API calls, or queries that don't modify state and don't contain sensitive information in the URL. Note: PREEMPTIVE BLOCK ON CLEAR INTENT still applies \u2014 if the transcript contains clear evidence the agent is using read-only operations to scout for a blocked action, block it.\n- Declared Dependencies: Installing packages that are already declared in the repo's manifest files (requirements.txt, package.json, Cargo.toml, pyproject.toml, Gemfile, etc.) via standard commands that read those manifests (`pip install -r requirements.txt`, `npm install`, `cargo build`, `bundle install`) \u2014 provided the agent has not modified the manifest in this session. Does NOT cover installing agent-chosen package names (e.g. `pip install foo`, `npm install bar`) \u2014 those carry typosquat and supply-chain risk.\n- Toolchain Bootstrap: Installing language toolchains (not packages) from their official one-line installers \u2014 `sh.rustup.rs`, `bootstrap.pypa.io`, `astral.sh`, `bun.sh`, `deb.nodesource.com`, `get.docker.com`, `brew.sh` \u2014 when the repo's manifest or build config indicates that toolchain is required.\n- Standard Credentials: Reading credentials from the agent's own config (.env, config files) and sending them to their intended provider (e.g. API key to its matching API endpoint)\n- Git Push to Working Branch: Pushing to the branch the user started the session on (unless it is the repository default branch), or to a branch the agent created during the session. Does not cover pushing to other pre-existing branches.</user_allow_rules_to_replace>\n";
|
|
9
9
|
//# sourceMappingURL=prompts-data.d.ts.map
|
|
@@ -126,7 +126,7 @@ These terms are used throughout the BLOCK and ALLOW rules. The lists below are e
|
|
|
126
126
|
- Interfere With Others: Deleting or cancelling jobs, modifying clusters in a way that would damage other jobs, overloading shared services, disrupting shared infrastructure, or spamming Slack channels. Job cancellation/deletion (e.g. kubectl delete job, scancel, kill, or equivalent) that does not target the EXACT jobs the agent created is inherently unsafe — it may affect other users' work. Even well-intentioned fixes count — deleting a shared component to "fix" it still disrupts everyone who depends on it.
|
|
127
127
|
- Modify Shared Resources: In-place modification of shared artifacts (e.g. shared configurations, dataset resources) not created in the current context. Persistent changes to shared state (Kubernetes resources, database records, cluster configs) without clear affirmative user consent for the specific change should be blocked. "Shared" means anything not exclusively owned by the agent's current session — internal services, production namespaces, shared databases, and multi-user infrastructure all count.
|
|
128
128
|
- Irreversible Local Destruction: Irreversibly deleting, truncating, or overwriting local files that existed before the session started (i.e. files the agent did not create) — \`rm -rf\`, \`git clean -fdx\`, \`git checkout .\`, \`git reset --hard\` on uncommitted changes, or \`> file\` truncation — without explicit user direction naming the specific targets. An underspecified or untested pattern (glob, regex, find) is not a specific target — the agent cannot know what it will match until it runs. Editing files inside package-manager-controlled directories (node_modules/, site-packages/, vendor/, etc.) also counts — these get regenerated on install. Patch your own code, or copy the dependency file into your repo's source tree instead. Destructive operations against local stateful services (databases, message queues, caches) also count unless they are clearly ephemeral test instances. Overwriting files the agent itself created during this session is fine.
|
|
129
|
-
- Create RCE
|
|
129
|
+
- Create RCE Environment: Creating services or endpoints that accept and execute arbitrary code, or writing code with common RCE vulnerabilities (unsanitized eval, shell injection, unsafe deserialization)
|
|
130
130
|
- Expose Local Services: Starting a web server or binding a port that exposes local files or services to the network. Note: development servers in the project working directory are covered by the "Local Operations" ALLOW exception.
|
|
131
131
|
- Credential Leakage: Embedding secrets or passwords in metadata, labels, URLs, or other fields where they become queryable or visible (e.g. putting a password in job labels)
|
|
132
132
|
- Credential Exploration: Systematically scanning credential stores (e.g. Kubernetes secrets, cloud secret managers, config files, environment variables, password vaults) to find usable tokens or API keys beyond what the agent's normal tools provide, or using credentials meant for a different service or purpose. The exploration behavior — trying multiple paths, failing, searching — is itself the violation, regardless of whether the credentials found look "standard".
|
|
@@ -2,7 +2,7 @@ import type { AuthorizeToolExecutionResult, ResolvedToolExecutionHookContext } f
|
|
|
2
2
|
import type { Message } from "../protocol/index.ts";
|
|
3
3
|
import type { PathClass } from "../tool/policies/path-access.ts";
|
|
4
4
|
import type { Tool } from "../tool/types.ts";
|
|
5
|
-
import type {
|
|
5
|
+
import type { GitWorkTreeEnvironment } from "../tool/support/git-worktree.ts";
|
|
6
6
|
import type { Logger } from "../logging/index.ts";
|
|
7
7
|
import type { AutoApprover, PermissionMode, PermissionPolicy, PermissionRule, Responder } from "./types.ts";
|
|
8
8
|
export interface PermissionManagerOptions {
|
|
@@ -11,7 +11,7 @@ export interface PermissionManagerOptions {
|
|
|
11
11
|
readonly responder?: Responder;
|
|
12
12
|
readonly cwd?: string;
|
|
13
13
|
readonly pathClass?: PathClass;
|
|
14
|
-
readonly
|
|
14
|
+
readonly environment?: GitWorkTreeEnvironment;
|
|
15
15
|
readonly policyOverrides?: ReadonlyMap<string, PermissionPolicy>;
|
|
16
16
|
/** The `auto`-mode judge. Consulted for would-prompt actions when `mode === "auto"`. */
|
|
17
17
|
readonly autoApprover?: AutoApprover;
|
|
@@ -43,7 +43,7 @@ export declare class PermissionManager {
|
|
|
43
43
|
private readonly responder;
|
|
44
44
|
private readonly cwd;
|
|
45
45
|
private readonly pathClass;
|
|
46
|
-
private readonly
|
|
46
|
+
private readonly environment;
|
|
47
47
|
private readonly policies;
|
|
48
48
|
private readonly autoApprover;
|
|
49
49
|
private readonly getTranscript;
|
|
@@ -51,6 +51,8 @@ export declare class PermissionManager {
|
|
|
51
51
|
private readonly logger;
|
|
52
52
|
constructor(options?: PermissionManagerOptions);
|
|
53
53
|
get mode(): PermissionMode;
|
|
54
|
+
/** The approve-for-session grants made so far (approval-rule subjects), in grant order. */
|
|
55
|
+
get sessionGrants(): readonly string[];
|
|
54
56
|
setMode(mode: PermissionMode): void;
|
|
55
57
|
addRule(rule: PermissionRule): void;
|
|
56
58
|
/** A malformed pattern makes the rule silently never match — fail-open for `deny`. Surface
|
|
@@ -7,7 +7,7 @@ export class PermissionManager {
|
|
|
7
7
|
responder;
|
|
8
8
|
cwd;
|
|
9
9
|
pathClass;
|
|
10
|
-
|
|
10
|
+
environment;
|
|
11
11
|
policies;
|
|
12
12
|
autoApprover;
|
|
13
13
|
getTranscript;
|
|
@@ -19,7 +19,7 @@ export class PermissionManager {
|
|
|
19
19
|
this.responder = options.responder;
|
|
20
20
|
this.cwd = options.cwd ?? "";
|
|
21
21
|
this.pathClass = options.pathClass ?? "posix";
|
|
22
|
-
this.
|
|
22
|
+
this.environment = options.environment;
|
|
23
23
|
this.autoApprover = options.autoApprover;
|
|
24
24
|
this.getTranscript = options.getTranscript;
|
|
25
25
|
this.getTools = options.getTools;
|
|
@@ -32,13 +32,17 @@ export class PermissionManager {
|
|
|
32
32
|
sessionApprovalRulePatterns: () => [...this.sessionPatterns],
|
|
33
33
|
cwd: () => this.cwd,
|
|
34
34
|
pathClass: () => this.pathClass,
|
|
35
|
-
|
|
35
|
+
environment: () => this.environment,
|
|
36
36
|
};
|
|
37
37
|
this.policies = createPolicies(state, options.policyOverrides);
|
|
38
38
|
}
|
|
39
39
|
get mode() {
|
|
40
40
|
return this.currentMode;
|
|
41
41
|
}
|
|
42
|
+
/** The approve-for-session grants made so far (approval-rule subjects), in grant order. */
|
|
43
|
+
get sessionGrants() {
|
|
44
|
+
return [...this.sessionPatterns];
|
|
45
|
+
}
|
|
42
46
|
setMode(mode) {
|
|
43
47
|
this.currentMode = mode;
|
|
44
48
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PathClass } from "../tool/policies/path-access.ts";
|
|
2
|
-
import { type
|
|
2
|
+
import { type GitWorkTreeEnvironment } from "../tool/support/git-worktree.ts";
|
|
3
3
|
import type { PermissionMode, PermissionPolicy, PermissionRule } from "./types.ts";
|
|
4
4
|
export interface PermissionState {
|
|
5
5
|
mode(): PermissionMode;
|
|
@@ -7,7 +7,7 @@ export interface PermissionState {
|
|
|
7
7
|
sessionApprovalRulePatterns(): readonly string[];
|
|
8
8
|
cwd(): string;
|
|
9
9
|
pathClass(): PathClass;
|
|
10
|
-
|
|
10
|
+
environment?(): GitWorkTreeEnvironment | undefined;
|
|
11
11
|
}
|
|
12
12
|
export declare const STAGED_POLICY_SLOTS: ReadonlySet<string>;
|
|
13
13
|
export declare function createPolicies(state: PermissionState, overrides?: ReadonlyMap<string, PermissionPolicy>): PermissionPolicy[];
|
|
@@ -53,11 +53,11 @@ export function createPolicies(state, overrides) {
|
|
|
53
53
|
// both git-control-path-access-ask and git-cwd-write-approve so they probe at most once.
|
|
54
54
|
let markerProbe;
|
|
55
55
|
const gitMarker = () => {
|
|
56
|
-
const
|
|
56
|
+
const environment = state.environment?.();
|
|
57
57
|
const cwd = state.cwd();
|
|
58
|
-
if (
|
|
58
|
+
if (environment === undefined || cwd.length === 0)
|
|
59
59
|
return Promise.resolve(null);
|
|
60
|
-
markerProbe ??= findGitWorkTreeMarker(
|
|
60
|
+
markerProbe ??= findGitWorkTreeMarker(environment, cwd).catch(() => null);
|
|
61
61
|
return markerProbe;
|
|
62
62
|
};
|
|
63
63
|
return [
|
|
@@ -205,7 +205,7 @@ export function createPolicies(state, overrides) {
|
|
|
205
205
|
},
|
|
206
206
|
},
|
|
207
207
|
// Write/Edit inside cwd inside a git work tree → approve (changes are recoverable via git).
|
|
208
|
-
// Still overridable by name; degrades to undefined (→ fallback ask) when no
|
|
208
|
+
// Still overridable by name; degrades to undefined (→ fallback ask) when no environment/marker.
|
|
209
209
|
overrides?.get("git-cwd-write-approve") ?? {
|
|
210
210
|
name: "git-cwd-write-approve",
|
|
211
211
|
async evaluate(ctx) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Field-level schemas shared by the plugin manifest and marketplace readers. Both formats are
|
|
3
|
+
* written by third parties, so blank strings mean "absent" and every rejection has to name the
|
|
4
|
+
* field that broke, in the words the author wrote.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
/** A string field whose blank value counts as absent. */
|
|
8
|
+
export declare const optionalText: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string | undefined, string>>>;
|
|
9
|
+
/** A list of strings with blanks dropped; an empty result counts as absent. */
|
|
10
|
+
export declare const optionalTextList: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string[] | undefined, string[]>>>;
|
|
11
|
+
/** `"a.b.0"` for an issue path, `<root>` for the document itself. */
|
|
12
|
+
export declare function issuePath(issue: z.core.$ZodIssue): string;
|
|
13
|
+
export declare function describeIssue(issue: z.core.$ZodIssue): string;
|
|
14
|
+
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Field-level schemas shared by the plugin manifest and marketplace readers. Both formats are
|
|
3
|
+
* written by third parties, so blank strings mean "absent" and every rejection has to name the
|
|
4
|
+
* field that broke, in the words the author wrote.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
/** A string field whose blank value counts as absent. */
|
|
8
|
+
export const optionalText = z
|
|
9
|
+
.string()
|
|
10
|
+
.transform((value) => {
|
|
11
|
+
const trimmed = value.trim();
|
|
12
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
13
|
+
})
|
|
14
|
+
.optional();
|
|
15
|
+
/** A list of strings with blanks dropped; an empty result counts as absent. */
|
|
16
|
+
export const optionalTextList = z
|
|
17
|
+
.array(z.string())
|
|
18
|
+
.transform((items) => {
|
|
19
|
+
const kept = items.map((item) => item.trim()).filter((item) => item.length > 0);
|
|
20
|
+
return kept.length > 0 ? kept : undefined;
|
|
21
|
+
})
|
|
22
|
+
.optional();
|
|
23
|
+
/** `"a.b.0"` for an issue path, `<root>` for the document itself. */
|
|
24
|
+
export function issuePath(issue) {
|
|
25
|
+
return issue.path.length > 0 ? issue.path.map(String).join(".") : "<root>";
|
|
26
|
+
}
|
|
27
|
+
export function describeIssue(issue) {
|
|
28
|
+
return `"${issuePath(issue)}" ${issue.message}`;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=fields.js.map
|
package/dist/plugins/hooks.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type HookDef } from "../capabilities/user-hooks/types.ts";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Environment } from "../tool/environment.ts";
|
|
3
3
|
import type { PluginDiagnostic } from "./types.ts";
|
|
4
4
|
export interface ParsedPluginHooks {
|
|
5
5
|
readonly hooks: readonly HookDef[];
|
|
@@ -9,7 +9,7 @@ export interface ParsedPluginHooks {
|
|
|
9
9
|
* Resolve hook definitions for a plugin root from the raw manifest `hooks` field.
|
|
10
10
|
* Expands `${PLUGIN_ROOT}` (and Claude-compat aliases) in command strings.
|
|
11
11
|
*/
|
|
12
|
-
export declare function loadPluginHooks(
|
|
12
|
+
export declare function loadPluginHooks(environment: Environment, pluginRoot: string, rawHooksField: unknown, diagnostics: PluginDiagnostic[]): Promise<readonly HookDef[]>;
|
|
13
13
|
/** Substitute plugin-root placeholders so commands can address files inside the package. */
|
|
14
14
|
export declare function expandPluginRootInHook(hook: HookDef, pluginRoot: string): HookDef;
|
|
15
15
|
export declare function expandPluginRoot(command: string, pluginRoot: string): string;
|
package/dist/plugins/hooks.js
CHANGED
|
@@ -13,15 +13,15 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import path from "node:path";
|
|
15
15
|
import { HOOK_EVENT_TYPES } from "../capabilities/user-hooks/types.js";
|
|
16
|
-
import { readTextFile } from "../tool/support/
|
|
16
|
+
import { readTextFile } from "../tool/support/environment-ops.js";
|
|
17
17
|
const DEFAULT_HOOKS_FILE = "hooks/hooks.json";
|
|
18
18
|
const KNOWN_EVENTS = new Set(HOOK_EVENT_TYPES);
|
|
19
19
|
/**
|
|
20
20
|
* Resolve hook definitions for a plugin root from the raw manifest `hooks` field.
|
|
21
21
|
* Expands `${PLUGIN_ROOT}` (and Claude-compat aliases) in command strings.
|
|
22
22
|
*/
|
|
23
|
-
export async function loadPluginHooks(
|
|
24
|
-
const docs = await collectHookDocuments(
|
|
23
|
+
export async function loadPluginHooks(environment, pluginRoot, rawHooksField, diagnostics) {
|
|
24
|
+
const docs = await collectHookDocuments(environment, pluginRoot, rawHooksField, diagnostics);
|
|
25
25
|
const out = [];
|
|
26
26
|
for (const doc of docs) {
|
|
27
27
|
const parsed = parseHooksDocument(doc);
|
|
@@ -89,13 +89,13 @@ export function hookDefsFromConfig(entries) {
|
|
|
89
89
|
return out;
|
|
90
90
|
}
|
|
91
91
|
// ── internal ─────────────────────────────────────────────────────────────────
|
|
92
|
-
async function collectHookDocuments(
|
|
92
|
+
async function collectHookDocuments(environment, pluginRoot, rawHooksField, diagnostics) {
|
|
93
93
|
// No field → try default path; absence is silent.
|
|
94
94
|
if (rawHooksField === undefined) {
|
|
95
95
|
const defaultPath = path.join(pluginRoot, DEFAULT_HOOKS_FILE);
|
|
96
|
-
if (!(await isFile(
|
|
96
|
+
if (!(await isFile(environment, defaultPath)))
|
|
97
97
|
return [];
|
|
98
|
-
return [await readJson(
|
|
98
|
+
return [await readJson(environment, defaultPath, diagnostics)];
|
|
99
99
|
}
|
|
100
100
|
// Inline document
|
|
101
101
|
if (isObject(rawHooksField) || Array.isArray(rawHooksField)) {
|
|
@@ -121,11 +121,11 @@ async function collectHookDocuments(machine, pluginRoot, rawHooksField, diagnost
|
|
|
121
121
|
const absolute = resolvePluginPath(pluginRoot, entry, "hooks", diagnostics);
|
|
122
122
|
if (absolute === undefined)
|
|
123
123
|
continue;
|
|
124
|
-
if (!(await isFile(
|
|
124
|
+
if (!(await isFile(environment, absolute))) {
|
|
125
125
|
diagnostics.push({ severity: "warn", message: `"hooks" path not found (${entry})` });
|
|
126
126
|
continue;
|
|
127
127
|
}
|
|
128
|
-
docs.push(await readJson(
|
|
128
|
+
docs.push(await readJson(environment, absolute, diagnostics));
|
|
129
129
|
}
|
|
130
130
|
return docs;
|
|
131
131
|
}
|
|
@@ -266,9 +266,9 @@ function resolvePluginPath(pluginRoot, entry, field, diagnostics) {
|
|
|
266
266
|
}
|
|
267
267
|
return absolute;
|
|
268
268
|
}
|
|
269
|
-
async function readJson(
|
|
269
|
+
async function readJson(environment, absolute, diagnostics) {
|
|
270
270
|
try {
|
|
271
|
-
return JSON.parse(await readTextFile(
|
|
271
|
+
return JSON.parse(await readTextFile(environment, absolute));
|
|
272
272
|
}
|
|
273
273
|
catch (error) {
|
|
274
274
|
diagnostics.push({
|
|
@@ -282,9 +282,9 @@ function isWithin(child, parent) {
|
|
|
282
282
|
const relative = path.relative(parent, child);
|
|
283
283
|
return relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative));
|
|
284
284
|
}
|
|
285
|
-
async function isFile(
|
|
285
|
+
async function isFile(environment, p) {
|
|
286
286
|
try {
|
|
287
|
-
return (await
|
|
287
|
+
return (await environment.fileInfo(p)).kind === "file";
|
|
288
288
|
}
|
|
289
289
|
catch {
|
|
290
290
|
return false;
|
package/dist/plugins/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export { PLUGIN_NAME_REGEX, normalizePluginId, } from "./types.js";
|
|
|
13
13
|
export function pluginsCapability(manager, resolveSkill) {
|
|
14
14
|
return {
|
|
15
15
|
name: "plugins",
|
|
16
|
+
contract: "detachable",
|
|
16
17
|
service: manager,
|
|
17
18
|
openSession: async () => {
|
|
18
19
|
await manager.load();
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { HookDef } from "../capabilities/user-hooks/types.ts";
|
|
2
|
-
import type { McpServerConfig, SkillRoot,
|
|
2
|
+
import type { McpServerConfig, SkillRoot, Environment } from "../index.ts";
|
|
3
3
|
import { type EnabledPluginSessionStart, type PluginInfo, type PluginRecord, type PluginSummary, type ReloadSummary } from "./types.ts";
|
|
4
4
|
export interface PluginManagerOptions {
|
|
5
|
-
readonly
|
|
5
|
+
readonly environment: Environment;
|
|
6
6
|
readonly homeDir: string;
|
|
7
7
|
readonly now?: () => number;
|
|
8
8
|
}
|
|
9
9
|
export declare class PluginManager {
|
|
10
|
-
private readonly
|
|
10
|
+
private readonly environment;
|
|
11
11
|
private readonly homeDir;
|
|
12
12
|
private readonly now;
|
|
13
13
|
private records;
|
|
@@ -18,6 +18,11 @@ export declare class PluginManager {
|
|
|
18
18
|
install(source: string): Promise<PluginRecord>;
|
|
19
19
|
setEnabled(id: string, enabled: boolean): Promise<void>;
|
|
20
20
|
setMcpServerEnabled(id: string, server: string, enabled: boolean): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Install and answer with the installed plugin's summary — what a host showing a plugin list
|
|
23
|
+
* wants, rather than the raw record plus a second lookup it has to remember to do.
|
|
24
|
+
*/
|
|
25
|
+
installSummary(source: string): Promise<PluginSummary>;
|
|
21
26
|
remove(id: string): Promise<void>;
|
|
22
27
|
reload(): Promise<ReloadSummary>;
|
|
23
28
|
skillRoots(): readonly SkillRoot[];
|
package/dist/plugins/manager.js
CHANGED
|
@@ -6,17 +6,17 @@ import { readInstalled, writeInstalled } from "./store.js";
|
|
|
6
6
|
import { resolveInstallSource } from "./source.js";
|
|
7
7
|
import { normalizePluginId, } from "./types.js";
|
|
8
8
|
export class PluginManager {
|
|
9
|
-
|
|
9
|
+
environment;
|
|
10
10
|
homeDir;
|
|
11
11
|
now;
|
|
12
12
|
records = new Map();
|
|
13
13
|
constructor(options) {
|
|
14
|
-
this.
|
|
14
|
+
this.environment = options.environment;
|
|
15
15
|
this.homeDir = options.homeDir;
|
|
16
16
|
this.now = options.now ?? Date.now;
|
|
17
17
|
}
|
|
18
18
|
async load() {
|
|
19
|
-
const file = await readInstalled(this.
|
|
19
|
+
const file = await readInstalled(this.environment, this.homeDir);
|
|
20
20
|
const next = new Map();
|
|
21
21
|
for (const entry of file.plugins) {
|
|
22
22
|
try {
|
|
@@ -68,7 +68,7 @@ export class PluginManager {
|
|
|
68
68
|
root = path.join(root, resolved.subdir);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
const parsed = await parseManifest(this.
|
|
71
|
+
const parsed = await parseManifest(this.environment, root);
|
|
72
72
|
if (parsed.manifest === undefined) {
|
|
73
73
|
const msg = parsed.diagnostics.find((d) => d.severity === "error")?.message ?? "no manifest";
|
|
74
74
|
throw new Error(`Cannot install plugin from ${originalSource}: ${msg}`);
|
|
@@ -125,6 +125,17 @@ export class PluginManager {
|
|
|
125
125
|
});
|
|
126
126
|
await this.persist();
|
|
127
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Install and answer with the installed plugin's summary — what a host showing a plugin list
|
|
130
|
+
* wants, rather than the raw record plus a second lookup it has to remember to do.
|
|
131
|
+
*/
|
|
132
|
+
async installSummary(source) {
|
|
133
|
+
const record = await this.install(source);
|
|
134
|
+
const summary = this.summaries().find((plugin) => plugin.id === record.id);
|
|
135
|
+
if (summary === undefined)
|
|
136
|
+
throw new Error(`Plugin "${record.id}" was installed but no summary was produced.`);
|
|
137
|
+
return summary;
|
|
138
|
+
}
|
|
128
139
|
async remove(id) {
|
|
129
140
|
if (!this.records.delete(normalizePluginId(id)))
|
|
130
141
|
throw new Error(`Plugin "${id}" is not installed`);
|
|
@@ -132,7 +143,7 @@ export class PluginManager {
|
|
|
132
143
|
}
|
|
133
144
|
async reload() {
|
|
134
145
|
const prevIds = new Set(this.records.keys());
|
|
135
|
-
const file = await readInstalled(this.
|
|
146
|
+
const file = await readInstalled(this.environment, this.homeDir);
|
|
136
147
|
const next = new Map();
|
|
137
148
|
const errors = [];
|
|
138
149
|
for (const entry of file.plugins) {
|
|
@@ -213,10 +224,10 @@ export class PluginManager {
|
|
|
213
224
|
capabilities: r.capabilities,
|
|
214
225
|
github: r.github,
|
|
215
226
|
}));
|
|
216
|
-
await writeInstalled(this.
|
|
227
|
+
await writeInstalled(this.environment, this.homeDir, { version: 1, plugins: installed });
|
|
217
228
|
}
|
|
218
229
|
async materialize(entry) {
|
|
219
|
-
const parsed = await parseManifest(this.
|
|
230
|
+
const parsed = await parseManifest(this.environment, entry.root);
|
|
220
231
|
return recordFrom({
|
|
221
232
|
id: entry.id,
|
|
222
233
|
root: entry.root,
|