typeclaw 0.50.0 → 0.52.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/dist/types/agent/bash-sandbox-env.d.ts +17 -0
- package/dist/types/agent/bash-sandbox-proc.d.ts +8 -0
- package/dist/types/agent/bash-sandbox.d.ts +98 -0
- package/dist/types/agent/compaction.d.ts +4 -4
- package/dist/types/agent/idle-compaction.d.ts +1 -0
- package/dist/types/agent/index.d.ts +10 -17
- package/dist/types/agent/multimodal/look-at.d.ts +1 -1
- package/dist/types/agent/output-allowance.d.ts +4 -0
- package/dist/types/agent/plugin-tools.d.ts +8 -75
- package/dist/types/agent/prompt-cache-key.d.ts +1 -0
- package/dist/types/agent/session-tail.d.ts +12 -0
- package/dist/types/agent/subagents.d.ts +5 -0
- package/dist/types/agent/system-prompt-composition.d.ts +18 -0
- package/dist/types/agent/system-prompt.d.ts +2 -0
- package/dist/types/agent/tools/channel-disengage.d.ts +1 -1
- package/dist/types/agent/tools/channel-edit.d.ts +1 -1
- package/dist/types/agent/tools/channel-fetch-attachment.d.ts +1 -1
- package/dist/types/agent/tools/channel-handoff.d.ts +1 -1
- package/dist/types/agent/tools/channel-history.d.ts +1 -1
- package/dist/types/agent/tools/channel-react.d.ts +1 -1
- package/dist/types/agent/tools/channel-read.d.ts +10 -2
- package/dist/types/agent/tools/channel-reply.d.ts +1 -1
- package/dist/types/agent/tools/channel-send.d.ts +1 -1
- package/dist/types/agent/tools/channel-session-search.d.ts +1 -1
- package/dist/types/agent/tools/ddg.d.ts +9 -0
- package/dist/types/agent/tools/grant-role.d.ts +1 -1
- package/dist/types/agent/tools/post-github-review.d.ts +1 -1
- package/dist/types/agent/tools/restart.d.ts +1 -1
- package/dist/types/agent/tools/skip-response.d.ts +1 -1
- package/dist/types/agent/tools/spawn-subagent.d.ts +2 -1
- package/dist/types/agent/tools/stream-snapshot.d.ts +2 -2
- package/dist/types/agent/tools/subagent-cancel.d.ts +1 -1
- package/dist/types/agent/tools/subagent-output.d.ts +1 -1
- package/dist/types/agent/tools/todo/index.d.ts +1 -1
- package/dist/types/agent/tools/webfetch/adaptive-html.d.ts +3 -3
- package/dist/types/agent/tools/webfetch/strategies/readability-process.d.ts +48 -0
- package/dist/types/agent/tools/webfetch/tool.d.ts +2 -2
- package/dist/types/agent/tools/websearch.d.ts +1 -1
- package/dist/types/channels/adapters/github/auth-app.d.ts +25 -0
- package/dist/types/channels/adapters/github/auth-pat.d.ts +17 -0
- package/dist/types/channels/adapters/github/auth.d.ts +24 -0
- package/dist/types/channels/github-review-check.d.ts +1 -1
- package/dist/types/channels/github-token-bridge.d.ts +4 -0
- package/dist/types/channels/lost-background-context.d.ts +2 -0
- package/dist/types/channels/persistence.d.ts +1 -0
- package/dist/types/channels/router.d.ts +16 -50
- package/dist/types/channels/types.d.ts +1 -0
- package/dist/types/coding-agent/tool.d.ts +1 -1
- package/dist/types/config/config.d.ts +22 -0
- package/dist/types/config/providers.d.ts +50 -1
- package/dist/types/container/start.d.ts +1 -0
- package/dist/types/eval/cell.d.ts +26 -0
- package/dist/types/eval/config.d.ts +19 -0
- package/dist/types/eval/dispatch.d.ts +7 -0
- package/dist/types/eval/kernel.d.ts +28 -0
- package/dist/types/eval/process.d.ts +23 -0
- package/dist/types/eval/protocol.d.ts +34 -0
- package/dist/types/eval/sandbox.d.ts +12 -0
- package/dist/types/eval/tool.d.ts +17 -0
- package/dist/types/eval/wire.d.ts +33 -0
- package/dist/types/git/resolve-identity.d.ts +2 -0
- package/dist/types/init/dockerfile.d.ts +1 -0
- package/dist/types/init/gitignore.d.ts +1 -1
- package/dist/types/permissions/builtins.d.ts +1 -0
- package/dist/types/plugin/types.d.ts +3 -0
- package/dist/types/sandbox/canonical-secrets.d.ts +2 -2
- package/dist/types/sandbox/coding-agent.d.ts +1 -1
- package/dist/types/sandbox/dependency-bins.d.ts +1 -0
- package/dist/types/sandbox/dev-source.d.ts +2 -2
- package/dist/types/sandbox/env-exposure.d.ts +2 -0
- package/dist/types/sandbox/hidden-paths.d.ts +1 -0
- package/dist/types/sandbox/index.d.ts +1 -1
- package/dist/types/sandbox/policy.d.ts +3 -0
- package/dist/types/typevault/cli-path.d.ts +2 -0
- package/dist/types/typevault/envelope-store.d.ts +11 -0
- package/dist/types/typevault/lifecycle.d.ts +13 -0
- package/dist/types/typevault/vault.d.ts +27 -0
- package/package.json +8 -7
- package/scripts/test.ts +252 -0
- package/src/agent/bash-sandbox-env.ts +136 -0
- package/src/agent/bash-sandbox-proc.ts +70 -0
- package/src/agent/bash-sandbox.ts +239 -0
- package/src/agent/compaction.ts +22 -10
- package/src/agent/idle-compaction.ts +7 -3
- package/src/agent/index.ts +185 -187
- package/src/agent/multimodal/look-at.ts +1 -1
- package/src/agent/output-allowance.ts +7 -0
- package/src/agent/plugin-tools.ts +64 -380
- package/src/agent/prompt-cache-key.ts +26 -3
- package/src/agent/session-origin.ts +41 -19
- package/src/agent/session-tail.ts +28 -0
- package/src/agent/subagent-completion-reminder.ts +2 -2
- package/src/agent/subagents.ts +21 -2
- package/src/agent/system-prompt-composition.ts +159 -0
- package/src/agent/system-prompt.ts +43 -5
- package/src/agent/todo/scope.ts +1 -1
- package/src/agent/tool-error-remediation.ts +18 -3
- package/src/agent/tools/channel-disengage.ts +1 -1
- package/src/agent/tools/channel-edit.ts +1 -1
- package/src/agent/tools/channel-fetch-attachment.ts +1 -1
- package/src/agent/tools/channel-handoff.ts +3 -2
- package/src/agent/tools/channel-history.ts +2 -1
- package/src/agent/tools/channel-react.ts +1 -1
- package/src/agent/tools/channel-read.ts +36 -3
- package/src/agent/tools/channel-reply.ts +1 -1
- package/src/agent/tools/channel-send.ts +4 -3
- package/src/agent/tools/channel-session-search.ts +13 -4
- package/src/agent/tools/ddg.ts +71 -11
- package/src/agent/tools/grant-role.ts +1 -1
- package/src/agent/tools/post-github-review.ts +1 -1
- package/src/agent/tools/restart.ts +1 -1
- package/src/agent/tools/skip-response.ts +1 -1
- package/src/agent/tools/spawn-subagent.ts +15 -1
- package/src/agent/tools/stream-snapshot.ts +1 -1
- package/src/agent/tools/subagent-cancel.ts +1 -1
- package/src/agent/tools/subagent-output.ts +1 -1
- package/src/agent/tools/todo/index.ts +1 -1
- package/src/agent/tools/webfetch/adaptive-html.ts +6 -4
- package/src/agent/tools/webfetch/strategies/readability-child.ts +25 -0
- package/src/agent/tools/webfetch/strategies/readability-process.ts +185 -0
- package/src/agent/tools/webfetch/tool.ts +6 -5
- package/src/agent/tools/websearch.ts +1 -1
- package/src/agent/tools-without-local-file-operands.ts +4 -0
- package/src/browser/dockerfile.ts +1 -1
- package/src/browser/fill-secret.ts +364 -0
- package/src/browser/registry.ts +6 -6
- package/src/bundled-plugins/agent-messenger-cli-auth/command.ts +211 -0
- package/src/bundled-plugins/agent-messenger-cli-auth/index.ts +186 -0
- package/src/bundled-plugins/backup/index.ts +17 -2
- package/src/bundled-plugins/backup/runner.ts +37 -2
- package/src/bundled-plugins/browser-agent/browser-agent.ts +51 -14
- package/src/bundled-plugins/browser-agent/index.ts +12 -5
- package/src/bundled-plugins/explorer/explorer.ts +1 -1
- package/src/bundled-plugins/github-cli-auth/gh-review-detect.ts +40 -16
- package/src/bundled-plugins/github-cli-auth/graphql-auth-nudge.ts +12 -7
- package/src/bundled-plugins/github-cli-auth/index.ts +10 -1
- package/src/bundled-plugins/managed-browser/index.ts +130 -2
- package/src/bundled-plugins/managed-browser/skills/browserskill/browserskill/SKILL.md +13 -5
- package/src/bundled-plugins/managed-browser/skills/omowright/omowright/SKILL.md +56 -5
- package/src/bundled-plugins/memory/README.md +23 -2
- package/src/bundled-plugins/memory/append-fragment.ts +133 -0
- package/src/bundled-plugins/memory/append-tool.ts +80 -149
- package/src/bundled-plugins/memory/dreaming.ts +6 -1
- package/src/bundled-plugins/memory/index.ts +33 -6
- package/src/bundled-plugins/memory/load-memory.ts +2 -4
- package/src/bundled-plugins/memory/memory-logger.ts +200 -6
- package/src/bundled-plugins/memory/references/store-reference-tool.ts +56 -32
- package/src/bundled-plugins/memory/remember-tool.ts +81 -0
- package/src/bundled-plugins/memory/search-tool-hybrid.ts +91 -0
- package/src/bundled-plugins/memory/search-tool.ts +58 -12
- package/src/bundled-plugins/memory/stream-events.ts +2 -0
- package/src/bundled-plugins/memory/transcript-cursor.ts +30 -0
- package/src/bundled-plugins/memory/transcript-preload.ts +208 -0
- package/src/bundled-plugins/memory/transcript-view.ts +36 -0
- package/src/bundled-plugins/memory/vector/hybrid.ts +25 -14
- package/src/bundled-plugins/memory/watermark.ts +19 -10
- package/src/bundled-plugins/reviewer/reviewer.ts +20 -0
- package/src/bundled-plugins/security/policies/outbound-secret-scan.ts +3 -6
- package/src/bundled-plugins/security/policies/outbound-text.ts +20 -0
- package/src/bundled-plugins/security/policies/private-surface-read.ts +166 -201
- package/src/bundled-plugins/security/policies/system-prompt-leak.ts +2 -7
- package/src/bundled-plugins/typevault/grants.ts +119 -0
- package/src/bundled-plugins/typevault/index.ts +152 -0
- package/src/bundled-plugins/typevault/request.ts +87 -0
- package/src/bundled-plugins/typevault/runtime.ts +45 -0
- package/src/bundled-plugins/typevault/skills/typevault/SKILL.md +65 -0
- package/src/channels/adapter-halt.ts +17 -0
- package/src/channels/adapters/discord-bot-reference.ts +5 -4
- package/src/channels/adapters/discord-bot.ts +1 -0
- package/src/channels/adapters/discord-classify.ts +8 -3
- package/src/channels/adapters/discord.ts +29 -0
- package/src/channels/adapters/github/history.ts +23 -2
- package/src/channels/adapters/github/inbound.ts +60 -1
- package/src/channels/adapters/github/index.ts +27 -5
- package/src/channels/adapters/github/reconcile-open-prs.ts +7 -1
- package/src/channels/adapters/kakaotalk-author-resolver.ts +7 -5
- package/src/channels/adapters/kakaotalk-channel-resolver.ts +45 -15
- package/src/channels/adapters/kakaotalk-classify.ts +7 -9
- package/src/channels/adapters/kakaotalk-list.ts +62 -0
- package/src/channels/adapters/kakaotalk-member-cache.ts +67 -0
- package/src/channels/adapters/kakaotalk-membership.ts +27 -10
- package/src/channels/adapters/kakaotalk-mention.ts +61 -0
- package/src/channels/adapters/kakaotalk.ts +159 -125
- package/src/channels/adapters/teams-classify.ts +18 -8
- package/src/channels/github-review-check.ts +5 -1
- package/src/channels/github-review-verdict-coordinator.ts +68 -2
- package/src/channels/github-token-bridge.ts +13 -0
- package/src/channels/lost-background-context.ts +46 -0
- package/src/channels/manager.ts +52 -3
- package/src/channels/persistence.ts +5 -0
- package/src/channels/router.ts +208 -128
- package/src/channels/schema.ts +1 -1
- package/src/channels/subagent-completion-bridge.ts +3 -2
- package/src/channels/types.ts +3 -0
- package/src/cli/hostd.ts +3 -0
- package/src/coding-agent/tool.ts +1 -1
- package/src/config/config.ts +35 -1
- package/src/config/providers.ts +75 -4
- package/src/container/start.ts +52 -3
- package/src/doctor/channel-checks.ts +33 -0
- package/src/doctor/checks.ts +37 -18
- package/src/doctor/index.ts +48 -12
- package/src/doctor/operational-incidents.ts +16 -1
- package/src/doctor/plugin-bridge.ts +14 -1
- package/src/doctor/stage.ts +14 -0
- package/src/doctor/types.ts +6 -0
- package/src/eval/cell.ts +93 -0
- package/src/eval/config.ts +32 -0
- package/src/eval/dispatch.ts +67 -0
- package/src/eval/entry.ts +261 -0
- package/src/eval/kernel.ts +154 -0
- package/src/eval/process.ts +113 -0
- package/src/eval/protocol.ts +26 -0
- package/src/eval/redeclare.ts +174 -0
- package/src/eval/sandbox.ts +117 -0
- package/src/eval/tool.ts +99 -0
- package/src/eval/wire.ts +93 -0
- package/src/git/resolve-identity.ts +67 -2
- package/src/git/system-commit.ts +7 -0
- package/src/init/dockerfile.ts +5 -1
- package/src/init/gitignore.ts +3 -3
- package/src/init/index.ts +1 -0
- package/src/init/models-dev.ts +2 -0
- package/src/init/validate-api-key.ts +5 -0
- package/src/migrations/secrets-v1-to-v2.ts +2 -0
- package/src/operations/classify-tool-outcome.ts +1 -1
- package/src/permissions/builtins.ts +8 -0
- package/src/plugin/core-tool-names.ts +6 -1
- package/src/plugin/types.ts +6 -0
- package/src/run/bundled-plugins.ts +12 -0
- package/src/run/channel-session-factory.ts +3 -0
- package/src/run/index.ts +13 -2
- package/src/sandbox/build.ts +1 -0
- package/src/sandbox/canonical-secrets.ts +6 -0
- package/src/sandbox/dependency-bins.ts +13 -1
- package/src/sandbox/dev-source.ts +21 -12
- package/src/sandbox/env-exposure.ts +20 -0
- package/src/sandbox/hidden-paths.ts +1 -1
- package/src/sandbox/index.ts +1 -0
- package/src/sandbox/policy.ts +5 -0
- package/src/secrets/hydrate.ts +4 -1
- package/src/secrets/storage.ts +10 -1
- package/src/server/command-runner.ts +4 -0
- package/src/server/index.ts +54 -12
- package/src/skills/typeclaw-config/SKILL.md +36 -2
- package/src/skills/typeclaw-memory/SKILL.md +3 -1
- package/src/skills/typeclaw-permissions/SKILL.md +8 -8
- package/src/skills/typeclaw-troubleshooting/SKILL.md +18 -1
- package/src/tunnels/active.ts +14 -0
- package/src/typevault/bash-cli.ts +18 -0
- package/src/typevault/cli-path.ts +11 -0
- package/src/typevault/envelope-helper.ts +17 -0
- package/src/typevault/envelope-store.ts +98 -0
- package/src/typevault/lifecycle.ts +132 -0
- package/src/typevault/prompt-tunnel.ts +33 -0
- package/src/typevault/redaction.ts +37 -0
- package/src/typevault/vault.ts +283 -0
- package/typeclaw.schema.json +92 -10
|
@@ -34,6 +34,8 @@ const PROVIDER_PROBE: Partial<Record<KnownProviderId, Probe>> = {
|
|
|
34
34
|
opengateway: { url: 'https://apis.opengateway.ai/v1/me', authHeader: 'bearer', successShape: 'json-object' },
|
|
35
35
|
// inception has no probe: its /v1/models is public and returns 200 for any
|
|
36
36
|
// key, so probing it would vouch for garbage.
|
|
37
|
+
// exaone has no probe: the platform documents only /v1/chat/completions, and an
|
|
38
|
+
// undocumented /v1/models could reject a valid key.
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
// When a base-URL override (ANTHROPIC_BASE_URL / OPENAI_BASE_URL) points at a
|
|
@@ -197,6 +199,9 @@ export const API_KEY_DASHBOARD_URL: Partial<Record<KnownProviderId, string>> = {
|
|
|
197
199
|
'moonshot-coding': 'https://www.kimi.com/code/console',
|
|
198
200
|
opengateway: 'https://opengateway.ai/docs/reference/guides/authentication',
|
|
199
201
|
inception: 'https://platform.inceptionlabs.ai',
|
|
202
|
+
// The overview page hosts the "Get an API Key" entry point; there is no
|
|
203
|
+
// separate console host.
|
|
204
|
+
exaone: 'https://docs.exaone.ai/en/docs/overview',
|
|
200
205
|
}
|
|
201
206
|
|
|
202
207
|
// MiniMax sells the same `minimax` provider under two billing surfaces that
|
|
@@ -4,6 +4,7 @@ import { join } from 'node:path'
|
|
|
4
4
|
import lockfile from 'proper-lockfile'
|
|
5
5
|
|
|
6
6
|
import { parseSecretsFile, SECRETS_FILE_VERSION } from '@/secrets/schema'
|
|
7
|
+
import { isTypevaultMarker } from '@/typevault/envelope-store'
|
|
7
8
|
|
|
8
9
|
// PR #638 removed the in-memory v1->v2 upgrade that `parseSecretsFile` used to
|
|
9
10
|
// perform, so a `secrets.json` still in v1 now fails to parse:
|
|
@@ -115,6 +116,7 @@ function upgradeFileInPlace(path: string): SecretsMigrationResult {
|
|
|
115
116
|
return { changed: false, summary: 'secrets file unreadable; skipped' }
|
|
116
117
|
}
|
|
117
118
|
if (raw.trim() === '') return { changed: false, summary: 'secrets file empty; skipped' }
|
|
119
|
+
if (isTypevaultMarker(raw)) return { changed: false, summary: 'secrets kept in TypeVault; skipped' }
|
|
118
120
|
|
|
119
121
|
let parsed: unknown
|
|
120
122
|
try {
|
|
@@ -41,7 +41,7 @@ const COMMAND_NOT_FOUND = new RegExp(
|
|
|
41
41
|
|
|
42
42
|
// Pi's grep/find reject with these fixed literals when `ensureTool` returns no
|
|
43
43
|
// rg/fd path (pi packages/coding-agent/src/core/tools/{grep,find}.ts; published
|
|
44
|
-
// dist/core/tools/{grep,find}.js, identical in 0.87.1, 0.99.2, and 1.
|
|
44
|
+
// dist/core/tools/{grep,find}.js, identical in 0.87.1, 0.99.2, 1.0.0, and 1.4.0).
|
|
45
45
|
// Classification accepts the literal alone or followed by the exact `: `
|
|
46
46
|
// separator and untrusted context. Context is never parsed or persisted; the
|
|
47
47
|
// bin comes only from the closed grep->rg/find->fd tool mapping. This contract
|
|
@@ -43,6 +43,11 @@ export const CORE_PERMISSIONS = {
|
|
|
43
43
|
// channels). Granted with fsSeePrivate because the browser's file exchange
|
|
44
44
|
// lives under workspace/, which that same tier already sees.
|
|
45
45
|
browserShared: 'browser.shared',
|
|
46
|
+
// With typevault enabled, the session's bash receives a live TypeVault grant
|
|
47
|
+
// for its role's tier (and every tier that tier includes). A grant can still
|
|
48
|
+
// read a value with `typevault get --reveal`, so the tier, not this
|
|
49
|
+
// permission, is what keeps one role's secrets from a lower role.
|
|
50
|
+
vaultUse: 'vault.use',
|
|
46
51
|
} as const
|
|
47
52
|
|
|
48
53
|
// Sentinel that `expandOwnerWildcard` swaps for the concrete union of
|
|
@@ -93,6 +98,7 @@ export const BUILTIN_ROLES: Readonly<Record<BuiltinRoleName, BuiltinRoleSpec>> =
|
|
|
93
98
|
CORE_PERMISSIONS.fsSeePrivate,
|
|
94
99
|
CORE_PERMISSIONS.browserShared,
|
|
95
100
|
CORE_PERMISSIONS.fsSeeSecrets,
|
|
101
|
+
CORE_PERMISSIONS.vaultUse,
|
|
96
102
|
'security.bypass.low',
|
|
97
103
|
'security.bypass.medium',
|
|
98
104
|
'security.bypass.high',
|
|
@@ -113,6 +119,7 @@ export const BUILTIN_ROLES: Readonly<Record<BuiltinRoleName, BuiltinRoleSpec>> =
|
|
|
113
119
|
CORE_PERMISSIONS.fsSeePrivate,
|
|
114
120
|
CORE_PERMISSIONS.browserShared,
|
|
115
121
|
CORE_PERMISSIONS.fsSeeSecrets,
|
|
122
|
+
CORE_PERMISSIONS.vaultUse,
|
|
116
123
|
'security.bypass.low',
|
|
117
124
|
'security.bypass.medium',
|
|
118
125
|
],
|
|
@@ -127,6 +134,7 @@ export const BUILTIN_ROLES: Readonly<Record<BuiltinRoleName, BuiltinRoleSpec>> =
|
|
|
127
134
|
CORE_PERMISSIONS.subagentOutput,
|
|
128
135
|
CORE_PERMISSIONS.fsSeePrivate,
|
|
129
136
|
CORE_PERMISSIONS.browserShared,
|
|
137
|
+
CORE_PERMISSIONS.vaultUse,
|
|
130
138
|
'security.bypass.low',
|
|
131
139
|
],
|
|
132
140
|
},
|
|
@@ -12,4 +12,9 @@ export const PI_BUILTIN_TOOL_NAMES: readonly PiBuiltinToolName[] = [
|
|
|
12
12
|
|
|
13
13
|
export const CORE_SYSTEM_TOOL_NAMES = ['web_search', 'web_fetch', 'look_at', 'coding_agent'] as const
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
// eval is conditional and must not enter the always-registered system catalog.
|
|
16
|
+
export const CORE_TOOL_NAMES: ReadonlySet<string> = new Set([
|
|
17
|
+
...PI_BUILTIN_TOOL_NAMES,
|
|
18
|
+
...CORE_SYSTEM_TOOL_NAMES,
|
|
19
|
+
'eval',
|
|
20
|
+
])
|
package/src/plugin/types.ts
CHANGED
|
@@ -21,6 +21,9 @@ export type ToolLogger = {
|
|
|
21
21
|
export type ToolContext = {
|
|
22
22
|
signal: AbortSignal | undefined
|
|
23
23
|
sessionId: string
|
|
24
|
+
readonly origin?: SessionOrigin
|
|
25
|
+
// Current transcript leaf at invocation; absent for tools called outside a session.
|
|
26
|
+
readonly entryId?: string
|
|
24
27
|
agentDir: string
|
|
25
28
|
logger: ToolLogger
|
|
26
29
|
}
|
|
@@ -56,6 +59,9 @@ export type SubagentContext<P = unknown> = {
|
|
|
56
59
|
|
|
57
60
|
export type RunSession = (override?: {
|
|
58
61
|
userPrompt?: string
|
|
62
|
+
// Trusted plugin handler override for this fresh session's system prompt.
|
|
63
|
+
// Payload fields are never forwarded here by the runtime.
|
|
64
|
+
systemPrompt?: string
|
|
59
65
|
// Called after a completed run with the terminal assistant text, or null
|
|
60
66
|
// after an empty terminal response or provider failure. No block projection.
|
|
61
67
|
onFinalMessage?: (message: string | null) => void
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import agentBrowserPlugin from '@/bundled-plugins/agent-browser'
|
|
2
|
+
import agentMessengerCliAuthPlugin from '@/bundled-plugins/agent-messenger-cli-auth'
|
|
2
3
|
import backupPlugin from '@/bundled-plugins/backup'
|
|
3
4
|
import browserAgentPlugin from '@/bundled-plugins/browser-agent'
|
|
4
5
|
import bunHygienePlugin from '@/bundled-plugins/bun-hygiene'
|
|
@@ -16,6 +17,7 @@ import reviewerPlugin from '@/bundled-plugins/reviewer'
|
|
|
16
17
|
import scoutPlugin from '@/bundled-plugins/scout'
|
|
17
18
|
import securityPlugin from '@/bundled-plugins/security'
|
|
18
19
|
import toolResultCapPlugin from '@/bundled-plugins/tool-result-cap'
|
|
20
|
+
import typevaultPlugin from '@/bundled-plugins/typevault'
|
|
19
21
|
import type { ResolvedPlugin } from '@/plugin'
|
|
20
22
|
|
|
21
23
|
// Consumed by both `startAgent` (auto-loaded before user plugins) AND
|
|
@@ -48,6 +50,14 @@ import type { ResolvedPlugin } from '@/plugin'
|
|
|
48
50
|
// ordering security first still matters so a blocked command never reaches the
|
|
49
51
|
// mint path at all.
|
|
50
52
|
//
|
|
53
|
+
// `agent-messenger-cli-auth` follows the same rule: security inspects the
|
|
54
|
+
// command before a channel bot token is minted into a CLI profile for it.
|
|
55
|
+
//
|
|
56
|
+
// `typevault` is registered right after `security` so its `tool.after`
|
|
57
|
+
// redaction sees the full tool output: if `tool-result-cap` truncated first, a
|
|
58
|
+
// secret cut at the cap boundary would no longer match and part of it could
|
|
59
|
+
// survive into the transcript.
|
|
60
|
+
//
|
|
51
61
|
// `memory` is registered before `backup` so memory's dreaming commits always
|
|
52
62
|
// land in the same git index window before backup's commit-and-push cycle.
|
|
53
63
|
// They commit disjoint paths today (memory/ vs sessions/ + agent changes),
|
|
@@ -55,10 +65,12 @@ import type { ResolvedPlugin } from '@/plugin'
|
|
|
55
65
|
// contention easier to reason about.
|
|
56
66
|
export const BUNDLED_PLUGINS: ResolvedPlugin[] = [
|
|
57
67
|
{ name: 'security', version: undefined, source: '<bundled>', defined: securityPlugin },
|
|
68
|
+
{ name: 'typevault', version: undefined, source: '<bundled>', defined: typevaultPlugin },
|
|
58
69
|
{ name: 'tool-result-cap', version: undefined, source: '<bundled>', defined: toolResultCapPlugin },
|
|
59
70
|
{ name: 'guard', version: undefined, source: '<bundled>', defined: guardPlugin },
|
|
60
71
|
{ name: 'bun-hygiene', version: undefined, source: '<bundled>', defined: bunHygienePlugin },
|
|
61
72
|
{ name: 'github-cli-auth', version: undefined, source: '<bundled>', defined: githubCliAuthPlugin },
|
|
73
|
+
{ name: 'agent-messenger-cli-auth', version: undefined, source: '<bundled>', defined: agentMessengerCliAuthPlugin },
|
|
62
74
|
{ name: 'memory', version: undefined, source: '<bundled>', defined: memoryPlugin },
|
|
63
75
|
{ name: 'backup', version: undefined, source: '<bundled>', defined: backupPlugin },
|
|
64
76
|
{ name: 'agent-browser', version: undefined, source: '<bundled>', defined: agentBrowserPlugin },
|
|
@@ -10,6 +10,7 @@ import type { CreateSessionForSubagent, SubagentCoalescer, SubagentRegistry } fr
|
|
|
10
10
|
import { capJsonlFileInPlace } from '@/bundled-plugins/tool-result-cap/cap-jsonl'
|
|
11
11
|
import type { CapOptions } from '@/bundled-plugins/tool-result-cap/cap-result'
|
|
12
12
|
import type { CreateSessionForChannel, ChannelRouter } from '@/channels'
|
|
13
|
+
import type { GetGithubSelf } from '@/channels/github-token-bridge'
|
|
13
14
|
import type { McpManager } from '@/mcp'
|
|
14
15
|
import type { PermissionService, RolesConfig } from '@/permissions'
|
|
15
16
|
import type { ReloadRegistry } from '@/reload'
|
|
@@ -29,6 +30,7 @@ const consoleLogger: FactoryLogger = {
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
export type BuildChannelSessionFactoryDeps = {
|
|
33
|
+
readonly getGithubSelf?: GetGithubSelf
|
|
32
34
|
cwd: string
|
|
33
35
|
sessionFactory: SessionFactory
|
|
34
36
|
stream: Stream
|
|
@@ -130,6 +132,7 @@ export function buildChannelSessionFactory(deps: BuildChannelSessionFactoryDeps)
|
|
|
130
132
|
|
|
131
133
|
const snap = deps.pluginRuntime.get()
|
|
132
134
|
const session = await createSession({
|
|
135
|
+
getGithubSelf: deps.getGithubSelf,
|
|
133
136
|
reloadRegistry: deps.reloadRegistry,
|
|
134
137
|
sessionManager,
|
|
135
138
|
stream: deps.stream,
|
package/src/run/index.ts
CHANGED
|
@@ -86,6 +86,8 @@ import { createSessionFactory, type SessionFactory } from '@/sessions'
|
|
|
86
86
|
import { createStream, type Stream } from '@/stream'
|
|
87
87
|
import { createTui as createTuiDefault, type TuiOptions } from '@/tui'
|
|
88
88
|
import { createTunnelManager, type TunnelManager, type TunnelManagerOptions } from '@/tunnels'
|
|
89
|
+
import { setActiveTunnelManager } from '@/tunnels/active'
|
|
90
|
+
import { runtimeTunnels } from '@/typevault/prompt-tunnel'
|
|
89
91
|
|
|
90
92
|
import { bootChannelRestartGreeting, bootBackgroundObligations } from './background-handoff-boot'
|
|
91
93
|
import { BUNDLED_PLUGINS } from './bundled-plugins'
|
|
@@ -444,13 +446,14 @@ async function startAgentRuntime(
|
|
|
444
446
|
})
|
|
445
447
|
|
|
446
448
|
const tunnelManager: TunnelManager = createTunnelManagerFor({
|
|
447
|
-
tunnels: getConfig()
|
|
449
|
+
tunnels: runtimeTunnels(getConfig()),
|
|
448
450
|
stream,
|
|
449
451
|
resolveChannelUpstreamPort: (name) => {
|
|
450
452
|
if (name === 'github') return getConfig().channels.github?.webhookPort ?? null
|
|
451
453
|
return null
|
|
452
454
|
},
|
|
453
455
|
})
|
|
456
|
+
setActiveTunnelManager(tunnelManager)
|
|
454
457
|
|
|
455
458
|
const legacyBackgroundHandoffs = new LegacyBackgroundHandoffReader(cwd, {
|
|
456
459
|
onError: (error) => console.warn(`[run] legacy background upgrade failed: ${error}`),
|
|
@@ -495,6 +498,7 @@ async function startAgentRuntime(
|
|
|
495
498
|
tunnelUrlForChannel: (name) => resolveTunnelUrlForChannel(name, tunnelManager),
|
|
496
499
|
tunnelConfiguredForChannel: (name) => isTunnelConfiguredForChannel(name),
|
|
497
500
|
createSessionForChannel: buildChannelSessionFactory({
|
|
501
|
+
getGithubSelf: githubTokenBridge.getSelf,
|
|
498
502
|
cwd,
|
|
499
503
|
sessionFactory,
|
|
500
504
|
stream,
|
|
@@ -583,7 +587,8 @@ async function startAgentRuntime(
|
|
|
583
587
|
const allowBackgroundFromSubagent =
|
|
584
588
|
entry.pluginSubagent.canBackgroundSpawnSubagents === true && entry.pluginSubagent.canSpawnSubagents === true
|
|
585
589
|
const created = await createSessionWithDispose({
|
|
586
|
-
|
|
590
|
+
getGithubSelf: githubTokenBridge.getSelf,
|
|
591
|
+
systemPromptOverride: subagentOptions?.systemPromptOverride ?? entry.pluginSubagent.systemPrompt,
|
|
587
592
|
sessionManager,
|
|
588
593
|
channelRouter: channelManager.router,
|
|
589
594
|
origin,
|
|
@@ -599,6 +604,7 @@ async function startAgentRuntime(
|
|
|
599
604
|
...(entry.pluginSubagent.tools ? { toolRefs: entry.pluginSubagent.tools } : {}),
|
|
600
605
|
...(entry.pluginSubagent.customTools ? { customTools: entry.pluginSubagent.customTools } : {}),
|
|
601
606
|
toolNamePrefix: `__plugin_${entry.pluginName}_${entry.subagentName}`,
|
|
607
|
+
...(entry.pluginSubagent.pluginTools ? { pluginToolNames: entry.pluginSubagent.pluginTools } : {}),
|
|
602
608
|
},
|
|
603
609
|
// Orchestration wiring is opt-in per subagent (canSpawnSubagents) so
|
|
604
610
|
// only operator/reviewer can delegate; explorer/scout/etc. stay leaves.
|
|
@@ -662,6 +668,7 @@ async function startAgentRuntime(
|
|
|
662
668
|
// attribution stay per-session).
|
|
663
669
|
const sessionManager = SessionManager.create(cwd, sessionFactory.sessionDir())
|
|
664
670
|
return defaultCreateSessionForSubagent(subagent, {
|
|
671
|
+
getGithubSelf: githubTokenBridge.getSelf,
|
|
665
672
|
...subagentOptions,
|
|
666
673
|
plugins: {
|
|
667
674
|
registry: snap.registry,
|
|
@@ -739,6 +746,7 @@ async function startAgentRuntime(
|
|
|
739
746
|
origin,
|
|
740
747
|
prompt: (text: string) =>
|
|
741
748
|
runPromptForCommand({
|
|
749
|
+
getGithubSelf: githubTokenBridge.getSelf,
|
|
742
750
|
text,
|
|
743
751
|
origin,
|
|
744
752
|
runtime: pluginRuntime,
|
|
@@ -783,6 +791,7 @@ async function startAgentRuntime(
|
|
|
783
791
|
console.error(`[cron] ${job.id}: clear todos failed: ${err instanceof Error ? err.message : String(err)}`),
|
|
784
792
|
)
|
|
785
793
|
const session = await createSession({
|
|
794
|
+
getGithubSelf: githubTokenBridge.getSelf,
|
|
786
795
|
reloadRegistry,
|
|
787
796
|
sessionManager,
|
|
788
797
|
stream,
|
|
@@ -1054,6 +1063,7 @@ async function startAgentRuntime(
|
|
|
1054
1063
|
|
|
1055
1064
|
const commandRunnerFactory = (outbound: import('@/server/command-runner').CommandOutbound): CommandRunner =>
|
|
1056
1065
|
createCommandRunner({
|
|
1066
|
+
getGithubSelf: githubTokenBridge.getSelf,
|
|
1057
1067
|
pluginRuntime,
|
|
1058
1068
|
permissions: pluginsLoaded.permissions,
|
|
1059
1069
|
spawnSubagent: dispatchSpawnSubagent,
|
|
@@ -1067,6 +1077,7 @@ async function startAgentRuntime(
|
|
|
1067
1077
|
})
|
|
1068
1078
|
|
|
1069
1079
|
const serverFactory = createServer({
|
|
1080
|
+
getGithubSelf: githubTokenBridge.getSelf,
|
|
1070
1081
|
port,
|
|
1071
1082
|
reloadAll: reloadAllNonDestructive,
|
|
1072
1083
|
reloadRegistry,
|
package/src/sandbox/build.ts
CHANGED
|
@@ -212,6 +212,7 @@ function buildArgv(command: string, policy: SandboxPolicy): string[] {
|
|
|
212
212
|
appendWritable(argv, policy)
|
|
213
213
|
appendMasks(argv, policy)
|
|
214
214
|
appendProtected(argv, policy)
|
|
215
|
+
for (const mount of policy.reveal ?? []) appendMount(argv, mount)
|
|
215
216
|
appendSymlinks(argv, policy)
|
|
216
217
|
|
|
217
218
|
if (policy.cwd !== undefined) {
|
|
@@ -16,6 +16,12 @@ export const RUNTIME_OWNED_SECRET_DIRS = [
|
|
|
16
16
|
'.typeclaw/home',
|
|
17
17
|
'.typeclaw/logs',
|
|
18
18
|
BROWSER_PROFILE_RELATIVE_DIR,
|
|
19
|
+
// TypeVault (typevault.enabled): the agent's machine key and typevault's
|
|
20
|
+
// private state, and the vault itself, which holds the secrets.json envelope.
|
|
21
|
+
// Mirrors src/typevault/vault.ts; kept as literals so the sandbox does not
|
|
22
|
+
// load the typevault SDK.
|
|
23
|
+
'.typeclaw/typevault',
|
|
24
|
+
'.typevault',
|
|
19
25
|
] as const
|
|
20
26
|
|
|
21
27
|
// SECURITY / classification: operator-provisioned CLI credential stores. TypeClaw
|
|
@@ -23,6 +23,10 @@ export async function reconcileDependencyBinWrappers(options: {
|
|
|
23
23
|
agentDir: string
|
|
24
24
|
sessionTmp: string
|
|
25
25
|
baselineDirs?: readonly string[]
|
|
26
|
+
// Runtime-provided commands (bin name -> entrypoint), e.g. the TypeVault CLI
|
|
27
|
+
// TypeClaw itself ships. Never derived from the agent's package.json, and
|
|
28
|
+
// they own their name even when an agent dependency ships the same bin.
|
|
29
|
+
runtimeBins?: Readonly<Record<string, string>>
|
|
26
30
|
}): Promise<DependencyBinReconciliation> {
|
|
27
31
|
const dir = join(options.sessionTmp, DEPENDENCY_BIN_DIR_NAME)
|
|
28
32
|
const previous = reconciliationLocks.get(dir) ?? Promise.resolve()
|
|
@@ -42,7 +46,12 @@ export async function reconcileDependencyBinWrappers(options: {
|
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
async function reconcileDependencyBinWrappersUnlocked(
|
|
45
|
-
options: {
|
|
49
|
+
options: {
|
|
50
|
+
agentDir: string
|
|
51
|
+
sessionTmp: string
|
|
52
|
+
baselineDirs?: readonly string[]
|
|
53
|
+
runtimeBins?: Readonly<Record<string, string>>
|
|
54
|
+
},
|
|
46
55
|
dir: string,
|
|
47
56
|
): Promise<DependencyBinReconciliation> {
|
|
48
57
|
const validation = await validateDependencyBins(options.agentDir, options.baselineDirs)
|
|
@@ -52,6 +61,9 @@ async function reconcileDependencyBinWrappersUnlocked(
|
|
|
52
61
|
if (resolution.kind !== 'package' || wrappers.has(resolution.declaration.bin)) continue
|
|
53
62
|
wrappers.set(resolution.declaration.bin, renderWrapper(resolution.containerEntrypoint))
|
|
54
63
|
}
|
|
64
|
+
for (const [bin, entrypoint] of Object.entries(options.runtimeBins ?? {})) {
|
|
65
|
+
wrappers.set(bin, renderWrapper(entrypoint))
|
|
66
|
+
}
|
|
55
67
|
for (const entry of await readdir(dir).catch(() => [])) {
|
|
56
68
|
if (entry.startsWith('.')) continue
|
|
57
69
|
if (!wrappers.has(entry)) await rm(join(dir, entry), { recursive: true, force: true })
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { realpath } from 'node:fs/promises'
|
|
2
|
-
import { dirname, isAbsolute, relative } from 'node:path'
|
|
1
|
+
import { realpath, stat } from 'node:fs/promises'
|
|
2
|
+
import { dirname, isAbsolute, join, relative } from 'node:path'
|
|
3
3
|
import { fileURLToPath } from 'node:url'
|
|
4
4
|
|
|
5
5
|
import type { SandboxMount } from './policy'
|
|
@@ -9,18 +9,27 @@ const RUNTIME_MODULE_FILE = fileURLToPath(import.meta.url)
|
|
|
9
9
|
// Dev mode (`file:`/`link:` typeclaw dep): files under node_modules/typeclaw
|
|
10
10
|
// are symlinks into a checkout outside the agent folder. `typeclaw start`
|
|
11
11
|
// mirror-mounts that checkout read-only into the container, but bwrap only
|
|
12
|
-
// binds the agent folder, so
|
|
13
|
-
// bash. Bind
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
|
|
12
|
+
// binds the agent folder, so anything typeclaw resolves inside the checkout
|
|
13
|
+
// dangles inside model bash. Bind the checkout's `src/` (bundled skills) and
|
|
14
|
+
// `node_modules/` (runtime-provided bins such as `typevault`, which resolve
|
|
15
|
+
// into typeclaw's own dependencies), never the checkout root, so a
|
|
16
|
+
// developer's `.env` or `.git` stays out of the sandbox. The path comes from
|
|
17
|
+
// the running module's own realpath, which the model cannot redirect by
|
|
18
|
+
// rewriting node_modules. Registry installs resolve inside the agent folder
|
|
19
|
+
// and get no mount.
|
|
20
|
+
export async function resolveDevSourceMounts(
|
|
19
21
|
agentDir: string,
|
|
20
22
|
moduleFile: string = RUNTIME_MODULE_FILE,
|
|
21
|
-
): Promise<Extract<SandboxMount, { type: 'ro-bind' }>
|
|
23
|
+
): Promise<Extract<SandboxMount, { type: 'ro-bind' }>[]> {
|
|
22
24
|
const srcDir = dirname(dirname(await realpath(moduleFile)))
|
|
23
25
|
const rel = relative(await realpath(agentDir), srcDir)
|
|
24
|
-
if (rel === '' || (!rel.startsWith('..') && !isAbsolute(rel))) return
|
|
25
|
-
|
|
26
|
+
if (rel === '' || (!rel.startsWith('..') && !isAbsolute(rel))) return []
|
|
27
|
+
const mounts: Extract<SandboxMount, { type: 'ro-bind' }>[] = [{ type: 'ro-bind', source: srcDir, dest: srcDir }]
|
|
28
|
+
const nodeModules = join(dirname(srcDir), 'node_modules')
|
|
29
|
+
// bwrap aborts on a missing bind source; a checkout that was never
|
|
30
|
+
// installed has nothing there to expose.
|
|
31
|
+
if ((await stat(nodeModules).catch(() => undefined))?.isDirectory()) {
|
|
32
|
+
mounts.push({ type: 'ro-bind', source: nodeModules, dest: nodeModules })
|
|
33
|
+
}
|
|
34
|
+
return mounts
|
|
26
35
|
}
|
|
@@ -54,6 +54,11 @@ const EXECUTION_CONTROL_ENV_NAMES = new Set<string>([
|
|
|
54
54
|
|
|
55
55
|
const EXECUTION_CONTROL_ENV_PREFIXES = ['GIT_CONFIG', 'BASH_FUNC_'] as const
|
|
56
56
|
|
|
57
|
+
// Operator opt-in for values the model may type into a page but never read:
|
|
58
|
+
// withheld from bash, reachable only through the runtime-side
|
|
59
|
+
// `browser_fill_secret` tool, which types the value without returning it.
|
|
60
|
+
export const SECRET_ENV_PREFIX = 'TYPECLAW_SECRET_'
|
|
61
|
+
|
|
57
62
|
const GIT_IDENTITY_ENV_NAMES = [
|
|
58
63
|
'GIT_AUTHOR_NAME',
|
|
59
64
|
'GIT_AUTHOR_EMAIL',
|
|
@@ -70,6 +75,7 @@ function isWithheldEnvName(name: string): boolean {
|
|
|
70
75
|
if (RESERVED_SANDBOX_ENV_NAMES.has(name)) return true
|
|
71
76
|
if (RUNTIME_OWNED_ENV_NAMES.has(name)) return true
|
|
72
77
|
if (EXECUTION_CONTROL_ENV_NAMES.has(name)) return true
|
|
78
|
+
if (name.startsWith(SECRET_ENV_PREFIX)) return true
|
|
73
79
|
return EXECUTION_CONTROL_ENV_PREFIXES.some((prefix) => name === prefix || name.startsWith(prefix))
|
|
74
80
|
}
|
|
75
81
|
|
|
@@ -94,3 +100,17 @@ export function resolveExposableEnvNames(
|
|
|
94
100
|
}
|
|
95
101
|
return out
|
|
96
102
|
}
|
|
103
|
+
|
|
104
|
+
// Names `browser_fill_secret` may type: everything bash already sees, plus the
|
|
105
|
+
// withheld `TYPECLAW_SECRET_*` tier. Runtime controls and sandbox-owned names
|
|
106
|
+
// stay out, so the tool can't plant a runtime token into a page for read-back.
|
|
107
|
+
export function resolveFillableEnvNames(
|
|
108
|
+
declaredEnv: ReadonlyMap<string, string>,
|
|
109
|
+
runtimeEnv: Readonly<Record<string, string | undefined>> = {},
|
|
110
|
+
): string[] {
|
|
111
|
+
const out = resolveExposableEnvNames(declaredEnv, runtimeEnv)
|
|
112
|
+
for (const [name, fileValue] of declaredEnv) {
|
|
113
|
+
if (fileValue.length > 0 && name.startsWith(SECRET_ENV_PREFIX)) out.push(name)
|
|
114
|
+
}
|
|
115
|
+
return out
|
|
116
|
+
}
|
|
@@ -63,7 +63,7 @@ export function canWriteAgentRootInSandbox(permissions: PermissionService, origi
|
|
|
63
63
|
return canSeePrivateSurface(permissions, origin) && seesSecrets
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
function canSeePrivateSurface(permissions: PermissionService, origin: SessionOrigin | undefined): boolean {
|
|
66
|
+
export function canSeePrivateSurface(permissions: PermissionService, origin: SessionOrigin | undefined): boolean {
|
|
67
67
|
return (
|
|
68
68
|
permissions.has(origin, CORE_PERMISSIONS.fsSeePrivate) ||
|
|
69
69
|
permissions.has(origin, 'security.bypass.low') ||
|
package/src/sandbox/index.ts
CHANGED
package/src/sandbox/policy.ts
CHANGED
|
@@ -132,6 +132,11 @@ export type SandboxPolicy = {
|
|
|
132
132
|
masks?: SandboxMaskPolicy
|
|
133
133
|
writable?: SandboxWritablePolicy
|
|
134
134
|
protected?: SandboxProtectedPolicy
|
|
135
|
+
// Read-only binds rendered AFTER masks and protected zones, so they deliberately
|
|
136
|
+
// re-expose one path a mask covers. Only trusted runtime hooks set these (the
|
|
137
|
+
// TypeVault plugin re-exposes the ciphertext-only vault and its grant socket
|
|
138
|
+
// to a session holding vault.use); never derive one from model input.
|
|
139
|
+
reveal?: Extract<SandboxMount, { type: 'ro-bind' | 'tmpfs' }>[]
|
|
135
140
|
symlinks?: SandboxSymlinkOp[]
|
|
136
141
|
network?: SandboxNetwork
|
|
137
142
|
env?: SandboxEnvPolicy
|
package/src/secrets/hydrate.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs'
|
|
2
|
-
import { join } from 'node:path'
|
|
2
|
+
import { dirname, join } from 'node:path'
|
|
3
|
+
|
|
4
|
+
import { isTypevaultMarker, readEnvelopeTextSync } from '@/typevault/envelope-store'
|
|
3
5
|
|
|
4
6
|
import { channelFieldDefaultEnv } from './defaults'
|
|
5
7
|
import { resolveSecret, secretFieldSchema, type Secret } from './resolve'
|
|
@@ -71,6 +73,7 @@ function readChannelSecrets(secretsPath: string): Record<string, Record<string,
|
|
|
71
73
|
let raw: string
|
|
72
74
|
try {
|
|
73
75
|
raw = readFileSync(secretsPath, 'utf8')
|
|
76
|
+
if (isTypevaultMarker(raw)) raw = readEnvelopeTextSync(dirname(secretsPath))
|
|
74
77
|
} catch {
|
|
75
78
|
return {}
|
|
76
79
|
}
|
package/src/secrets/storage.ts
CHANGED
|
@@ -5,6 +5,8 @@ import type { AuthOperationOptions, Credential, CredentialInfo, CredentialStore
|
|
|
5
5
|
import { operationSignal, raceWithAbortSignal } from '@earendil-works/pi-ai/utils/abort'
|
|
6
6
|
import lockfile from 'proper-lockfile'
|
|
7
7
|
|
|
8
|
+
import { isTypevaultMarker, readEnvelopeTextSync, writeEnvelopeTextSync } from '@/typevault/envelope-store'
|
|
9
|
+
|
|
8
10
|
import { providerKeyDefaultEnv } from './defaults'
|
|
9
11
|
import { resolveSecret } from './resolve'
|
|
10
12
|
import {
|
|
@@ -511,7 +513,8 @@ export class SecretsBackend implements CredentialStore {
|
|
|
511
513
|
}
|
|
512
514
|
|
|
513
515
|
private readEnvelope(): SecretsFile {
|
|
514
|
-
const
|
|
516
|
+
const onDisk = existsSync(this.secretsPath) ? readFileSync(this.secretsPath, 'utf8') : ''
|
|
517
|
+
const raw = isTypevaultMarker(onDisk) ? readEnvelopeTextSync(dirname(this.secretsPath)) : onDisk
|
|
515
518
|
if (!raw.trim()) return newEmptyEnvelope()
|
|
516
519
|
let parsed: unknown
|
|
517
520
|
try {
|
|
@@ -527,6 +530,12 @@ export class SecretsBackend implements CredentialStore {
|
|
|
527
530
|
}
|
|
528
531
|
|
|
529
532
|
private writeEnvelopeAtomic(envelope: SecretsFile): void {
|
|
533
|
+
// With typevault enabled, secrets.json is only the marker; the envelope
|
|
534
|
+
// itself is written into the vault and the marker is never rewritten.
|
|
535
|
+
if (existsSync(this.secretsPath) && isTypevaultMarker(readFileSync(this.secretsPath, 'utf8'))) {
|
|
536
|
+
writeEnvelopeTextSync(dirname(this.secretsPath), stringifyEnvelope(envelope))
|
|
537
|
+
return
|
|
538
|
+
}
|
|
530
539
|
const tmp = `${this.secretsPath}.${process.pid}.${Date.now()}.${tempSequence++}.tmp`
|
|
531
540
|
writeFileSync(tmp, stringifyEnvelope(envelope), { encoding: 'utf8', mode: FILE_MODE })
|
|
532
541
|
try {
|
|
@@ -37,6 +37,7 @@ export type CommandOutbound = {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
export type CommandRunnerOptions = {
|
|
40
|
+
readonly getGithubSelf?: CreateSessionOptions['getGithubSelf']
|
|
40
41
|
pluginRuntime: PluginRuntime
|
|
41
42
|
permissions: PermissionService
|
|
42
43
|
spawnSubagent: CommandSpawnSubagent
|
|
@@ -190,6 +191,7 @@ export function createCommandRunner(opts: CommandRunnerOptions): CommandRunner {
|
|
|
190
191
|
origin,
|
|
191
192
|
prompt: (text) =>
|
|
192
193
|
runPromptForCommand({
|
|
194
|
+
getGithubSelf: opts.getGithubSelf,
|
|
193
195
|
text,
|
|
194
196
|
origin,
|
|
195
197
|
runtime: opts.pluginRuntime,
|
|
@@ -413,6 +415,7 @@ function drainWrites(stream: WritableStream<Uint8Array>): Promise<void> {
|
|
|
413
415
|
export type CreateSessionForCommand = (options: CreateSessionOptions) => Promise<CreateSessionResult>
|
|
414
416
|
|
|
415
417
|
export async function runPromptForCommand(args: {
|
|
418
|
+
readonly getGithubSelf?: CreateSessionOptions['getGithubSelf']
|
|
416
419
|
text: string
|
|
417
420
|
origin: SessionOrigin
|
|
418
421
|
runtime: PluginRuntime
|
|
@@ -446,6 +449,7 @@ export async function runPromptForCommand(args: {
|
|
|
446
449
|
const sessionId = resolveSessionIdForOrigin(args.origin)
|
|
447
450
|
const create = args._createSession ?? createSessionWithDispose
|
|
448
451
|
const { session, dispose } = await create({
|
|
452
|
+
getGithubSelf: args.getGithubSelf,
|
|
449
453
|
origin: args.origin,
|
|
450
454
|
permissions: args.permissions,
|
|
451
455
|
sessionManager: args.sessionFactory.createPersisted(),
|