typeclaw 0.48.0 → 0.48.2
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/package.json +1 -1
- package/src/agent/plugin-tools.ts +68 -9
- package/src/agent/system-prompt.ts +8 -0
- package/src/agent-messenger/config-dir.ts +131 -0
- package/src/agent-messenger/host-config-dir.ts +121 -0
- package/src/bundled-plugins/guard/policies/managed-config.ts +7 -20
- package/src/bundled-plugins/guard/policies/non-workspace-write.ts +7 -20
- package/src/bundled-plugins/guard/policies/skill-authoring.ts +8 -20
- package/src/bundled-plugins/memory/README.md +2 -0
- package/src/bundled-plugins/memory/dreaming.ts +2 -0
- package/src/bundled-plugins/security/policies/private-surface-read.ts +10 -23
- package/src/cli/channel.ts +15 -16
- package/src/cli/hostd.ts +8 -13
- package/src/cli/init.ts +21 -7
- package/src/cli/model.ts +6 -3
- package/src/cli/restart.ts +13 -15
- package/src/compose/restart.ts +14 -6
- package/src/config/providers.ts +106 -143
- package/src/container/agent-operation-lock.ts +85 -0
- package/src/container/controller.ts +6 -0
- package/src/container/index.ts +8 -0
- package/src/container/restart.ts +55 -0
- package/src/container/shared.ts +5 -0
- package/src/container/start.ts +112 -4
- package/src/container/stop.ts +17 -1
- package/src/hostd/daemon.ts +1 -1
- package/src/hostd/paths.ts +17 -0
- package/src/hostd/supervisor.ts +27 -10
- package/src/init/dockerfile.ts +6 -5
- package/src/init/env-file.ts +42 -18
- package/src/init/instagram-auth.ts +55 -31
- package/src/init/kakaotalk-auth.ts +1 -5
- package/src/init/line-auth.ts +45 -29
- package/src/init/models-dev.ts +114 -7
- package/src/init/opengateway-catalog.ts +120 -0
- package/src/path-safety/real-intended-path.ts +111 -0
- package/src/sandbox/canonical-secrets.ts +10 -1
- package/src/sandbox/errors.ts +0 -32
- package/src/sandbox/privileged-runtime.ts +8 -94
- package/src/test-helpers/fake-agent-operation-lock.ts +66 -0
- package/typeclaw.schema.json +10 -30
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
|
|
3
|
+
// Canonicalizes the longest RESOLVABLE prefix of an absolute path, then re-appends
|
|
4
|
+
// the remainder lexically. A bare realpath throws on a path that does not exist yet
|
|
5
|
+
// (a write target, or a read of a not-yet-created file), so we walk up to the nearest
|
|
6
|
+
// resolvable ancestor, realpath THAT — collapsing every symlinked component, including
|
|
7
|
+
// a planted one — and rejoin the tail. This is what catches `public/leak/x` where
|
|
8
|
+
// `public/leak` is a symlink into a hidden dir even though `public/leak/x` itself does
|
|
9
|
+
// not exist.
|
|
10
|
+
//
|
|
11
|
+
// Which errnos may be walked past is the security-sensitive part, so it is the
|
|
12
|
+
// CALLER's decision, not a default. See the two exported sets below.
|
|
13
|
+
|
|
14
|
+
// The historical, strictest set: only a missing component is walked past.
|
|
15
|
+
// Correct for allowlist/authorization policies, where an unresolvable component must
|
|
16
|
+
// never widen what is permitted.
|
|
17
|
+
export const RECOVER_MISSING: ReadonlySet<string> = new Set(['ENOENT'])
|
|
18
|
+
|
|
19
|
+
// Adds EACCES for denylist matching. A realpath of a path under a directory the
|
|
20
|
+
// runtime cannot search fails with EACCES, not ENOENT — e.g. resolving
|
|
21
|
+
// `/root/.config/...` while running as a non-root uid when `/root` is mode 700.
|
|
22
|
+
// Treating that as fatal blocks reads of paths that are neither secret nor denied.
|
|
23
|
+
// Walking past it is sound for a DENYLIST because the tail is still matched against
|
|
24
|
+
// the denied surface after rejoining: a masked directory still matches lexically and
|
|
25
|
+
// still blocks. It is NOT sound for an allowlist — see RECOVER_MISSING.
|
|
26
|
+
export const RECOVER_MISSING_OR_UNSEARCHABLE: ReadonlySet<string> = new Set(['ENOENT', 'EACCES'])
|
|
27
|
+
|
|
28
|
+
export type RealIntendedPathOptions = {
|
|
29
|
+
// Defaults to RECOVER_MISSING: callers must opt in to the broader set.
|
|
30
|
+
readonly recoverable?: ReadonlySet<string>
|
|
31
|
+
// What to do when even the filesystem root is unresolvable. Callers that treat an
|
|
32
|
+
// unresolvable path as a hard failure use 'throw'; callers that fall back to the
|
|
33
|
+
// lexical input use 'return-input'.
|
|
34
|
+
readonly onExhausted?: 'throw' | 'return-input'
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function realIntendedPathSync(
|
|
38
|
+
absolutePath: string,
|
|
39
|
+
realpath: (candidate: string) => string,
|
|
40
|
+
options: RealIntendedPathOptions = {},
|
|
41
|
+
): string {
|
|
42
|
+
const walk = createAncestorWalk(absolutePath, options)
|
|
43
|
+
while (true) {
|
|
44
|
+
let resolved: string
|
|
45
|
+
try {
|
|
46
|
+
resolved = realpath(walk.target())
|
|
47
|
+
} catch (error) {
|
|
48
|
+
const exhausted = walk.retreat(error)
|
|
49
|
+
if (exhausted !== undefined) return exhausted
|
|
50
|
+
continue
|
|
51
|
+
}
|
|
52
|
+
return walk.rejoin(resolved)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function realIntendedPath(
|
|
57
|
+
absolutePath: string,
|
|
58
|
+
realpath: (candidate: string) => Promise<string>,
|
|
59
|
+
options: RealIntendedPathOptions = {},
|
|
60
|
+
): Promise<string> {
|
|
61
|
+
const walk = createAncestorWalk(absolutePath, options)
|
|
62
|
+
while (true) {
|
|
63
|
+
let resolved: string
|
|
64
|
+
try {
|
|
65
|
+
resolved = await realpath(walk.target())
|
|
66
|
+
} catch (error) {
|
|
67
|
+
const exhausted = walk.retreat(error)
|
|
68
|
+
if (exhausted !== undefined) return exhausted
|
|
69
|
+
continue
|
|
70
|
+
}
|
|
71
|
+
return walk.rejoin(resolved)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
type AncestorWalk = {
|
|
76
|
+
target(): string
|
|
77
|
+
rejoin(resolvedTarget: string): string
|
|
78
|
+
// Returns the final result when the walk cannot retreat further, or undefined to
|
|
79
|
+
// keep walking. Rethrows anything the caller did not declare recoverable.
|
|
80
|
+
retreat(error: unknown): string | undefined
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function createAncestorWalk(absolutePath: string, options: RealIntendedPathOptions): AncestorWalk {
|
|
84
|
+
const recoverable = options.recoverable ?? RECOVER_MISSING
|
|
85
|
+
const onExhausted = options.onExhausted ?? 'return-input'
|
|
86
|
+
const pending: string[] = []
|
|
87
|
+
let current = absolutePath
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
target: () => current,
|
|
91
|
+
// Copy before reversing: the caller may hold this array across iterations.
|
|
92
|
+
rejoin: (resolvedTarget) => path.join(resolvedTarget, ...[...pending].reverse()),
|
|
93
|
+
retreat(error) {
|
|
94
|
+
if (!isRecoverableErrno(error, recoverable)) throw error
|
|
95
|
+
const parent = path.dirname(current)
|
|
96
|
+
if (parent === current) {
|
|
97
|
+
if (onExhausted === 'throw') throw new Error(`could not resolve existing parent for ${absolutePath}`)
|
|
98
|
+
return absolutePath
|
|
99
|
+
}
|
|
100
|
+
pending.push(path.basename(current))
|
|
101
|
+
current = parent
|
|
102
|
+
return undefined
|
|
103
|
+
},
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function isRecoverableErrno(error: unknown, recoverable: ReadonlySet<string>): boolean {
|
|
108
|
+
if (!(error instanceof Error) || !('code' in error)) return false
|
|
109
|
+
const code = (error as { code: unknown }).code
|
|
110
|
+
return typeof code === 'string' && recoverable.has(code)
|
|
111
|
+
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AGENT_MESSENGER_CONFIG_RELATIVE_DIR,
|
|
3
|
+
LEGACY_AGENT_MESSENGER_CONFIG_RELATIVE_DIR,
|
|
4
|
+
} from '@/agent-messenger/config-dir'
|
|
5
|
+
|
|
1
6
|
export const CANONICAL_AGENT_SECRET_DIRS = [
|
|
2
7
|
'workspace/.config/gws',
|
|
3
|
-
|
|
8
|
+
AGENT_MESSENGER_CONFIG_RELATIVE_DIR,
|
|
9
|
+
// Retained permanently for interrupted migrations, operator backups under
|
|
10
|
+
// the old name, and older installs. This is not an active config location.
|
|
11
|
+
LEGACY_AGENT_MESSENGER_CONFIG_RELATIVE_DIR,
|
|
4
12
|
'.typeclaw/home',
|
|
5
13
|
'.typeclaw/logs',
|
|
6
14
|
] as const
|
|
@@ -17,6 +25,7 @@ export const CANONICAL_HOME_SECRET_DIRS = [
|
|
|
17
25
|
'.ssh',
|
|
18
26
|
'.config/gh',
|
|
19
27
|
'.config/gws',
|
|
28
|
+
'.config/agent-messenger',
|
|
20
29
|
'.agent-messenger',
|
|
21
30
|
'.codex',
|
|
22
31
|
'.claude',
|
package/src/sandbox/errors.ts
CHANGED
|
@@ -26,38 +26,6 @@ export class SandboxPolicyError extends Error {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
// Raised when model-driven bash invokes an agent-messenger CLI. TypeClaw never
|
|
30
|
-
// brokers those reusable auth profiles (resolvePrivilegedSandboxRuntime) AND
|
|
31
|
-
// masks the whole `workspace/.agent-messenger` directory, so the CLI can never
|
|
32
|
-
// authenticate here — every platform resolves credentials from a
|
|
33
|
-
// `<platform>-credentials.json` file, never from the environment.
|
|
34
|
-
//
|
|
35
|
-
// The refusal MUST announce itself. A silent one lets the uncredentialed CLI
|
|
36
|
-
// print its own "No current workspace set. Run `auth extract` first.", which the
|
|
37
|
-
// model reads as a fact about the WORLD — and it will then tell a human the
|
|
38
|
-
// runtime has no workspace authentication, laundering a local policy decision
|
|
39
|
-
// into a false claim about the upstream service. The CLI is honest about ITS
|
|
40
|
-
// state; it has no way to know it was deliberately deprived.
|
|
41
|
-
//
|
|
42
|
-
// Hence the message states its own provenance: what was withheld, that the
|
|
43
|
-
// decision is local, that retrying cannot help, and which mediated tool does
|
|
44
|
-
// work. The last part is load-bearing — a dead end the model cannot route
|
|
45
|
-
// around produces exactly the confabulation this class exists to prevent.
|
|
46
|
-
export class SandboxCredentialWithheldError extends Error {
|
|
47
|
-
override readonly name = 'SandboxCredentialWithheldError'
|
|
48
|
-
constructor(executable: string) {
|
|
49
|
-
super(
|
|
50
|
-
`credential withheld by TypeClaw policy: \`${executable}\` cannot authenticate in model-driven bash. ` +
|
|
51
|
-
'TypeClaw never brokers an agent-messenger auth profile to a model-controlled child (the CLI can upload ' +
|
|
52
|
-
'arbitrary files, so a brokered credential would make it a confused deputy), and its credential directory ' +
|
|
53
|
-
'is masked. This is a LOCAL sandbox policy decision. It is NOT evidence that the workspace, account, or ' +
|
|
54
|
-
'upstream service lacks authentication — do not report it as such. Retrying, running `auth extract`, or ' +
|
|
55
|
-
'switching package runner will not change it. Use the mediated channel_* tools instead (channel_read, ' +
|
|
56
|
-
'channel_history, channel_send), which run inside TypeClaw with the configured channel credential.',
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
29
|
// Raised when the /proc strategy degraded to the empty `tmpfs` fallback AND the
|
|
62
30
|
// command needs a real /proc (bunx / bun run that reads the
|
|
63
31
|
// kernel-backed /proc/self/{fd,maps}). Without this pre-check Bun aborts deep in
|
|
@@ -2,7 +2,7 @@ import { chmod, lstat, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises
|
|
|
2
2
|
import { homedir, tmpdir } from 'node:os'
|
|
3
3
|
import path from 'node:path'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { SandboxPolicyError } from './errors'
|
|
6
6
|
import type { SandboxMount } from './policy'
|
|
7
7
|
|
|
8
8
|
const SAFE_GIT_SUBCOMMANDS = new Set([
|
|
@@ -30,49 +30,6 @@ const SAFE_GIT_SUBCOMMANDS = new Set([
|
|
|
30
30
|
|
|
31
31
|
const SHELL_ACTIVE = new Set(['|', ';', '&', '\n', '\r', '(', ')', '{', '}', '<', '>', '`', '$', '\\'])
|
|
32
32
|
|
|
33
|
-
// The exact bins agent-messenger installs, kept in lockstep with the installed
|
|
34
|
-
// manifest by a test. Reserving the whole `agent-*` namespace instead would
|
|
35
|
-
// over-claim AND under-claim: an unrelated user-installed `agent-lint` would be
|
|
36
|
-
// refused with a false agent-messenger credential claim — the very class of
|
|
37
|
-
// false statement this refusal exists to prevent — while `amsg`, a real
|
|
38
|
-
// agent-messenger bin, carries no `agent-` prefix and would slip through.
|
|
39
|
-
export const AGENT_MESSENGER_BINS: ReadonlySet<string> = new Set([
|
|
40
|
-
'agent-channeltalk',
|
|
41
|
-
'agent-channeltalkbot',
|
|
42
|
-
'agent-discord',
|
|
43
|
-
'agent-discordbot',
|
|
44
|
-
'agent-imessage',
|
|
45
|
-
'agent-instagram',
|
|
46
|
-
'agent-kakaotalk',
|
|
47
|
-
'agent-line',
|
|
48
|
-
'agent-messenger',
|
|
49
|
-
'agent-slack',
|
|
50
|
-
'agent-slackbot',
|
|
51
|
-
'agent-teams',
|
|
52
|
-
'agent-telegram',
|
|
53
|
-
'agent-telegrambot',
|
|
54
|
-
'agent-webex',
|
|
55
|
-
'agent-webexbot',
|
|
56
|
-
'agent-wechatbot',
|
|
57
|
-
'agent-whatsapp',
|
|
58
|
-
'agent-whatsappbot',
|
|
59
|
-
'amsg',
|
|
60
|
-
])
|
|
61
|
-
|
|
62
|
-
// Ephemeral runners that execute a package bin named by their first operand.
|
|
63
|
-
// `bunx` is the bare-binary alias for `bun x` (see sandbox/package-install.ts);
|
|
64
|
-
// npx/pnpx are the non-bun spellings the bun-hygiene guard still permits.
|
|
65
|
-
const PACKAGE_RUNNERS = new Set(['bunx', 'npx', 'pnpx'])
|
|
66
|
-
const BUN_RUNNER_SUBCOMMANDS = new Set(['x', 'run'])
|
|
67
|
-
|
|
68
|
-
// Splits at the shell operators that begin a NEW simple command, mirroring
|
|
69
|
-
// `commandNeedsRealProc`. Deliberately coarse: it over-splits inside quotes and
|
|
70
|
-
// `$()`, but this feeds a DENY-ONLY decision, so a spurious extra segment can
|
|
71
|
-
// only make the refusal MORE likely — it can never grant a credential.
|
|
72
|
-
const SHELL_COMMAND_SEPARATOR = /(?:&&|\|\||[;|&\n()<>])+/
|
|
73
|
-
|
|
74
|
-
const ENV_ASSIGNMENT = /^[A-Za-z_][A-Za-z0-9_]*=/
|
|
75
|
-
|
|
76
33
|
export type PrivilegedSandboxRuntime = {
|
|
77
34
|
env: Record<string, string>
|
|
78
35
|
mounts: SandboxMount[]
|
|
@@ -89,7 +46,6 @@ export async function resolvePrivilegedSandboxRuntime(options: {
|
|
|
89
46
|
env?: NodeJS.ProcessEnv
|
|
90
47
|
homeDir?: string
|
|
91
48
|
}): Promise<PrivilegedSandboxRuntime> {
|
|
92
|
-
rejectAgentMessengerCommand(options.command)
|
|
93
49
|
const runtime = emptyRuntime()
|
|
94
50
|
// TYPECLAW_GIT_TOKEN is set only after the auth analyzer accepts a Git command.
|
|
95
51
|
// Trust that decision rather than reparsing its command with a less capable
|
|
@@ -106,26 +62,13 @@ export async function resolvePrivilegedSandboxRuntime(options: {
|
|
|
106
62
|
const executable = unwrapBunx(parsed)
|
|
107
63
|
if (executable === null) return runtime
|
|
108
64
|
|
|
109
|
-
//
|
|
110
|
-
// and `
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
//
|
|
116
|
-
// auth profile to a model-controlled child would therefore make the CLI a
|
|
117
|
-
// confused deputy even when the outer shell is syntactically standalone.
|
|
118
|
-
//
|
|
119
|
-
// They stay executable-but-uncredentialed rather than refused outright: an
|
|
120
|
-
// operator CAN authenticate them from `.env`, which model bash does inherit,
|
|
121
|
-
// so refusing would break working setups. The agent-messenger family cannot —
|
|
122
|
-
// every platform reads a `<platform>-credentials.json` file under the
|
|
123
|
-
// unconditionally masked `workspace/.agent-messenger` — so it is a guaranteed
|
|
124
|
-
// dead end and is refused loudly above instead of failing misleadingly.
|
|
125
|
-
if (executable.executable === 'gws' || executable.executable === 'codex' || executable.executable === 'claude') {
|
|
126
|
-
return runtime
|
|
127
|
-
}
|
|
128
|
-
|
|
65
|
+
// Credentials are default-deny: only an explicit broker below grants a
|
|
66
|
+
// profile, and `git` is the only broker. Do not add executable-name checks
|
|
67
|
+
// here. The confused-deputy argument belongs to the default, not to a list of
|
|
68
|
+
// names — it holds for every model-controlled child that can print or upload
|
|
69
|
+
// files, including ones not yet written. A name list is also where beliefs
|
|
70
|
+
// about a tool's credential layout accumulate; one such belief was wrong and
|
|
71
|
+
// refused a working CLI family outright. See this file's history.
|
|
129
72
|
if (executable.executable === 'git') {
|
|
130
73
|
runtime.env.GIT_CONFIG_GLOBAL = '/dev/null'
|
|
131
74
|
runtime.env.GIT_CONFIG_NOSYSTEM = '1'
|
|
@@ -148,35 +91,6 @@ function containsGitInvocation(command: string): boolean {
|
|
|
148
91
|
return /(^|[;&|]\s*)git(?:\s|$)/.test(command.trim())
|
|
149
92
|
}
|
|
150
93
|
|
|
151
|
-
function rejectAgentMessengerCommand(command: string): void {
|
|
152
|
-
for (const segment of command.split(SHELL_COMMAND_SEPARATOR)) {
|
|
153
|
-
const bin = agentMessengerBinIn(segment)
|
|
154
|
-
if (bin !== undefined) throw new SandboxCredentialWithheldError(bin)
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function agentMessengerBinIn(segment: string): string | undefined {
|
|
159
|
-
const words = segment
|
|
160
|
-
.trim()
|
|
161
|
-
.split(/\s+/)
|
|
162
|
-
.map((word) => word.replaceAll(/^["']|["']$/g, ''))
|
|
163
|
-
.filter((word) => word !== '' && !ENV_ASSIGNMENT.test(word))
|
|
164
|
-
const operand = unwrapPackageRunner(words).find((word) => !word.startsWith('-'))
|
|
165
|
-
if (operand === undefined) return undefined
|
|
166
|
-
const bin = path.basename(operand)
|
|
167
|
-
return AGENT_MESSENGER_BINS.has(bin) ? bin : undefined
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function unwrapPackageRunner(words: readonly string[]): readonly string[] {
|
|
171
|
-
const head = words[0]
|
|
172
|
-
if (head === undefined) return words
|
|
173
|
-
const runner = path.basename(head)
|
|
174
|
-
if (PACKAGE_RUNNERS.has(runner)) return words.slice(1)
|
|
175
|
-
const subcommand = words[1]
|
|
176
|
-
if (runner === 'bun' && subcommand !== undefined && BUN_RUNNER_SUBCOMMANDS.has(subcommand)) return words.slice(2)
|
|
177
|
-
return words
|
|
178
|
-
}
|
|
179
|
-
|
|
180
94
|
export async function verifyPrivilegedSandboxRuntime(runtime: PrivilegedSandboxRuntime): Promise<void> {
|
|
181
95
|
const identities = mountedIdentities.get(runtime) ?? new Map()
|
|
182
96
|
for (const mount of runtime.mounts) {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { resolve } from 'node:path'
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
AgentOperation,
|
|
5
|
+
AgentOperationLease,
|
|
6
|
+
AgentOperationLockResult,
|
|
7
|
+
WithAgentOperationLock,
|
|
8
|
+
} from '@/container/agent-operation-lock'
|
|
9
|
+
import { containerNameFromCwd } from '@/container/shared'
|
|
10
|
+
|
|
11
|
+
export class FakeAgentOperationCoordinator {
|
|
12
|
+
readonly events: string[] = []
|
|
13
|
+
readonly operationLock: WithAgentOperationLock
|
|
14
|
+
|
|
15
|
+
private readonly active = new Set<string>()
|
|
16
|
+
|
|
17
|
+
constructor(private readonly contentionReason = 'contended') {
|
|
18
|
+
this.operationLock = async <T>(
|
|
19
|
+
input: { agentDir: string; operation: AgentOperation; lease?: AgentOperationLease },
|
|
20
|
+
run: (lease: AgentOperationLease) => Promise<T>,
|
|
21
|
+
): Promise<AgentOperationLockResult<T>> => {
|
|
22
|
+
const agentDir = resolve(input.agentDir)
|
|
23
|
+
const containerName = containerNameFromCwd(agentDir)
|
|
24
|
+
const lease = { containerName, agentDir }
|
|
25
|
+
if (input.lease !== undefined) {
|
|
26
|
+
if (input.lease.containerName !== containerName || resolve(input.lease.agentDir) !== agentDir) {
|
|
27
|
+
return { ok: false, reason: 'mismatched lease' }
|
|
28
|
+
}
|
|
29
|
+
return { ok: true, value: await run(input.lease) }
|
|
30
|
+
}
|
|
31
|
+
if (this.active.has(containerName)) {
|
|
32
|
+
this.events.push(`lock-contention:${input.operation}`)
|
|
33
|
+
return { ok: false, reason: this.contentionReason }
|
|
34
|
+
}
|
|
35
|
+
this.active.add(containerName)
|
|
36
|
+
this.events.push(`lock-enter:${input.operation}`)
|
|
37
|
+
try {
|
|
38
|
+
return { ok: true, value: await run(lease) }
|
|
39
|
+
} finally {
|
|
40
|
+
this.events.push(`lock-exit:${input.operation}`)
|
|
41
|
+
this.active.delete(containerName)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
park(): { entered: Promise<void>; wait: () => Promise<void>; release: () => void } {
|
|
47
|
+
const entered = deferred()
|
|
48
|
+
const released = deferred()
|
|
49
|
+
return {
|
|
50
|
+
entered: entered.promise,
|
|
51
|
+
wait: async () => {
|
|
52
|
+
entered.resolve()
|
|
53
|
+
await released.promise
|
|
54
|
+
},
|
|
55
|
+
release: () => released.resolve(),
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function deferred(): { promise: Promise<void>; resolve: () => void } {
|
|
61
|
+
let resolvePromise: () => void = () => {}
|
|
62
|
+
const promise = new Promise<void>((resolve) => {
|
|
63
|
+
resolvePromise = resolve
|
|
64
|
+
})
|
|
65
|
+
return { promise, resolve: resolvePromise }
|
|
66
|
+
}
|
package/typeclaw.schema.json
CHANGED
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"minimax/MiniMax-M2",
|
|
58
58
|
"deepseek/deepseek-v4-flash",
|
|
59
59
|
"deepseek/deepseek-v4-pro",
|
|
60
|
+
"upstage/solar-pro4",
|
|
60
61
|
"upstage/solar-open2",
|
|
61
62
|
"upstage/solar-pro3",
|
|
62
63
|
"upstage/solar-pro2",
|
|
@@ -65,12 +66,7 @@
|
|
|
65
66
|
"moonshot/kimi-k2.6",
|
|
66
67
|
"moonshot/kimi-k2.5",
|
|
67
68
|
"moonshot-coding/kimi-for-coding",
|
|
68
|
-
"opengateway/openai/gpt-5.4-nano"
|
|
69
|
-
"opengateway/openai/gpt-5.5",
|
|
70
|
-
"opengateway/anthropic/claude-sonnet-5",
|
|
71
|
-
"opengateway/anthropic/claude-opus-4-8",
|
|
72
|
-
"opengateway/moonshotai/kimi-k2.6",
|
|
73
|
-
"opengateway/minimax/MiniMax-M3"
|
|
69
|
+
"opengateway/openai/gpt-5.4-nano"
|
|
74
70
|
]
|
|
75
71
|
},
|
|
76
72
|
{
|
|
@@ -119,6 +115,7 @@
|
|
|
119
115
|
"minimax/MiniMax-M2",
|
|
120
116
|
"deepseek/deepseek-v4-flash",
|
|
121
117
|
"deepseek/deepseek-v4-pro",
|
|
118
|
+
"upstage/solar-pro4",
|
|
122
119
|
"upstage/solar-open2",
|
|
123
120
|
"upstage/solar-pro3",
|
|
124
121
|
"upstage/solar-pro2",
|
|
@@ -127,12 +124,7 @@
|
|
|
127
124
|
"moonshot/kimi-k2.6",
|
|
128
125
|
"moonshot/kimi-k2.5",
|
|
129
126
|
"moonshot-coding/kimi-for-coding",
|
|
130
|
-
"opengateway/openai/gpt-5.4-nano"
|
|
131
|
-
"opengateway/openai/gpt-5.5",
|
|
132
|
-
"opengateway/anthropic/claude-sonnet-5",
|
|
133
|
-
"opengateway/anthropic/claude-opus-4-8",
|
|
134
|
-
"opengateway/moonshotai/kimi-k2.6",
|
|
135
|
-
"opengateway/minimax/MiniMax-M3"
|
|
127
|
+
"opengateway/openai/gpt-5.4-nano"
|
|
136
128
|
]
|
|
137
129
|
},
|
|
138
130
|
{
|
|
@@ -182,6 +174,7 @@
|
|
|
182
174
|
"minimax/MiniMax-M2",
|
|
183
175
|
"deepseek/deepseek-v4-flash",
|
|
184
176
|
"deepseek/deepseek-v4-pro",
|
|
177
|
+
"upstage/solar-pro4",
|
|
185
178
|
"upstage/solar-open2",
|
|
186
179
|
"upstage/solar-pro3",
|
|
187
180
|
"upstage/solar-pro2",
|
|
@@ -190,12 +183,7 @@
|
|
|
190
183
|
"moonshot/kimi-k2.6",
|
|
191
184
|
"moonshot/kimi-k2.5",
|
|
192
185
|
"moonshot-coding/kimi-for-coding",
|
|
193
|
-
"opengateway/openai/gpt-5.4-nano"
|
|
194
|
-
"opengateway/openai/gpt-5.5",
|
|
195
|
-
"opengateway/anthropic/claude-sonnet-5",
|
|
196
|
-
"opengateway/anthropic/claude-opus-4-8",
|
|
197
|
-
"opengateway/moonshotai/kimi-k2.6",
|
|
198
|
-
"opengateway/minimax/MiniMax-M3"
|
|
186
|
+
"opengateway/openai/gpt-5.4-nano"
|
|
199
187
|
]
|
|
200
188
|
},
|
|
201
189
|
{
|
|
@@ -243,6 +231,7 @@
|
|
|
243
231
|
"minimax/MiniMax-M2",
|
|
244
232
|
"deepseek/deepseek-v4-flash",
|
|
245
233
|
"deepseek/deepseek-v4-pro",
|
|
234
|
+
"upstage/solar-pro4",
|
|
246
235
|
"upstage/solar-open2",
|
|
247
236
|
"upstage/solar-pro3",
|
|
248
237
|
"upstage/solar-pro2",
|
|
@@ -251,12 +240,7 @@
|
|
|
251
240
|
"moonshot/kimi-k2.6",
|
|
252
241
|
"moonshot/kimi-k2.5",
|
|
253
242
|
"moonshot-coding/kimi-for-coding",
|
|
254
|
-
"opengateway/openai/gpt-5.4-nano"
|
|
255
|
-
"opengateway/openai/gpt-5.5",
|
|
256
|
-
"opengateway/anthropic/claude-sonnet-5",
|
|
257
|
-
"opengateway/anthropic/claude-opus-4-8",
|
|
258
|
-
"opengateway/moonshotai/kimi-k2.6",
|
|
259
|
-
"opengateway/minimax/MiniMax-M3"
|
|
243
|
+
"opengateway/openai/gpt-5.4-nano"
|
|
260
244
|
]
|
|
261
245
|
},
|
|
262
246
|
{
|
|
@@ -305,6 +289,7 @@
|
|
|
305
289
|
"minimax/MiniMax-M2",
|
|
306
290
|
"deepseek/deepseek-v4-flash",
|
|
307
291
|
"deepseek/deepseek-v4-pro",
|
|
292
|
+
"upstage/solar-pro4",
|
|
308
293
|
"upstage/solar-open2",
|
|
309
294
|
"upstage/solar-pro3",
|
|
310
295
|
"upstage/solar-pro2",
|
|
@@ -313,12 +298,7 @@
|
|
|
313
298
|
"moonshot/kimi-k2.6",
|
|
314
299
|
"moonshot/kimi-k2.5",
|
|
315
300
|
"moonshot-coding/kimi-for-coding",
|
|
316
|
-
"opengateway/openai/gpt-5.4-nano"
|
|
317
|
-
"opengateway/openai/gpt-5.5",
|
|
318
|
-
"opengateway/anthropic/claude-sonnet-5",
|
|
319
|
-
"opengateway/anthropic/claude-opus-4-8",
|
|
320
|
-
"opengateway/moonshotai/kimi-k2.6",
|
|
321
|
-
"opengateway/minimax/MiniMax-M3"
|
|
301
|
+
"opengateway/openai/gpt-5.4-nano"
|
|
322
302
|
]
|
|
323
303
|
},
|
|
324
304
|
{
|