typeclaw 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -13
- package/auth.schema.json +41 -0
- package/cron.schema.json +8 -0
- package/package.json +1 -1
- package/secrets.schema.json +41 -0
- package/src/agent/auth.ts +45 -22
- package/src/agent/index.ts +189 -19
- package/src/agent/multimodal/index.ts +12 -0
- package/src/agent/multimodal/look-at.ts +185 -0
- package/src/agent/multimodal/looker.ts +145 -0
- package/src/agent/plugin-tools.ts +30 -1
- package/src/agent/session-origin.ts +194 -46
- package/src/agent/subagents.ts +57 -1
- package/src/agent/system-prompt.ts +1 -1
- package/src/agent/tool-result-budget.ts +121 -0
- package/src/bundled-plugins/backup/index.ts +23 -8
- package/src/bundled-plugins/backup/runner.ts +22 -0
- package/src/bundled-plugins/memory/README.md +13 -10
- package/src/bundled-plugins/memory/append-tool.ts +87 -61
- package/src/bundled-plugins/memory/dreaming.ts +137 -7
- package/src/bundled-plugins/memory/find-entry-tool.ts +62 -0
- package/src/bundled-plugins/memory/fragment-parser.ts +19 -44
- package/src/bundled-plugins/memory/index.ts +91 -8
- package/src/bundled-plugins/memory/load-memory.ts +74 -34
- package/src/bundled-plugins/memory/memory-logger.ts +72 -29
- package/src/bundled-plugins/memory/migration.ts +276 -0
- package/src/bundled-plugins/memory/stream-events.ts +55 -0
- package/src/bundled-plugins/memory/stream-io.ts +63 -0
- package/src/bundled-plugins/memory/watermark.ts +48 -8
- package/src/bundled-plugins/security/index.ts +103 -10
- package/src/bundled-plugins/security/permissions.ts +12 -0
- package/src/bundled-plugins/security/policies/git-exfil.ts +51 -18
- package/src/bundled-plugins/tool-result-cap/README.md +9 -4
- package/src/bundled-plugins/tool-result-cap/cap-jsonl.ts +115 -0
- package/src/bundled-plugins/tool-result-cap/cap-result.ts +25 -13
- package/src/bundled-plugins/tool-result-cap/index.ts +16 -2
- package/src/channels/adapters/discord-bot-classify.ts +2 -6
- package/src/channels/adapters/discord-bot.ts +4 -45
- package/src/channels/adapters/kakaotalk-classify.ts +3 -7
- package/src/channels/adapters/kakaotalk.ts +28 -47
- package/src/channels/adapters/slack-bot-classify.ts +2 -6
- package/src/channels/adapters/slack-bot.ts +4 -50
- package/src/channels/adapters/telegram-bot-classify.ts +8 -10
- package/src/channels/adapters/telegram-bot.ts +3 -16
- package/src/channels/index.ts +3 -2
- package/src/channels/manager.ts +15 -1
- package/src/channels/persistence.ts +44 -10
- package/src/channels/router.ts +228 -19
- package/src/channels/schema.ts +6 -156
- package/src/cli/channel.ts +200 -4
- package/src/cli/compose-usage.ts +182 -0
- package/src/cli/compose.ts +33 -0
- package/src/cli/hostd.ts +49 -1
- package/src/cli/index.ts +4 -0
- package/src/cli/init.ts +809 -300
- package/src/cli/model.ts +244 -0
- package/src/cli/provider.ts +404 -0
- package/src/cli/reload.ts +11 -3
- package/src/cli/role.ts +156 -0
- package/src/cli/run.ts +3 -1
- package/src/cli/tui.ts +13 -3
- package/src/cli/usage-args.ts +47 -0
- package/src/cli/usage.ts +97 -0
- package/src/compose/index.ts +1 -0
- package/src/compose/usage.ts +65 -0
- package/src/config/config.ts +491 -19
- package/src/config/index.ts +15 -1
- package/src/config/models-mutation.ts +200 -0
- package/src/config/providers-mutation.ts +250 -0
- package/src/config/providers.ts +141 -2
- package/src/config/reloadable.ts +15 -4
- package/src/container/index.ts +6 -1
- package/src/container/port.ts +10 -0
- package/src/container/require-running.ts +33 -0
- package/src/container/start.ts +81 -63
- package/src/cron/consumer.ts +22 -2
- package/src/cron/index.ts +45 -4
- package/src/cron/schema.ts +104 -0
- package/src/doctor/checks.ts +51 -34
- package/src/doctor/plugin-bridge.ts +28 -4
- package/src/git/system-commit.ts +103 -0
- package/src/hostd/daemon.ts +16 -0
- package/src/hostd/kakao-renewal-manager.ts +223 -0
- package/src/hostd/paths.ts +7 -0
- package/src/init/dockerfile.ts +36 -10
- package/src/init/gitignore.ts +1 -1
- package/src/init/index.ts +213 -85
- package/src/init/kakaotalk-auth.ts +18 -1
- package/src/init/models-dev.ts +26 -1
- package/src/init/run-owner-claim.ts +77 -0
- package/src/permissions/builtins.ts +70 -0
- package/src/permissions/grant.ts +99 -0
- package/src/permissions/index.ts +29 -0
- package/src/permissions/match-rule.ts +305 -0
- package/src/permissions/permissions.ts +196 -0
- package/src/permissions/resolve.ts +80 -0
- package/src/permissions/schema.ts +79 -0
- package/src/plugin/context.ts +8 -4
- package/src/plugin/define.ts +2 -0
- package/src/plugin/index.ts +2 -0
- package/src/plugin/manager.ts +41 -0
- package/src/plugin/registry.ts +9 -0
- package/src/plugin/types.ts +35 -1
- package/src/reload/client.ts +25 -1
- package/src/role-claim/client.ts +182 -0
- package/src/role-claim/code.ts +53 -0
- package/src/role-claim/controller.ts +194 -0
- package/src/role-claim/index.ts +19 -0
- package/src/role-claim/match-rule.ts +43 -0
- package/src/role-claim/pending.ts +100 -0
- package/src/run/channel-session-factory.ts +76 -5
- package/src/run/index.ts +68 -7
- package/src/secrets/encryption.ts +116 -0
- package/src/secrets/kakao-renewal.ts +248 -0
- package/src/secrets/kakao-store.ts +66 -7
- package/src/secrets/keys.ts +173 -0
- package/src/secrets/schema.ts +23 -0
- package/src/secrets/storage.ts +83 -0
- package/src/server/index.ts +198 -71
- package/src/shared/index.ts +4 -0
- package/src/shared/protocol.ts +27 -0
- package/src/skills/typeclaw-channel-kakaotalk/SKILL.md +3 -3
- package/src/skills/typeclaw-config/SKILL.md +104 -112
- package/src/skills/typeclaw-memory/SKILL.md +9 -9
- package/src/skills/typeclaw-permissions/SKILL.md +166 -0
- package/src/stream/types.ts +7 -1
- package/src/tui/client.ts +66 -5
- package/src/tui/index.ts +61 -9
- package/src/usage/aggregate.ts +117 -0
- package/src/usage/format.ts +30 -0
- package/src/usage/index.ts +68 -0
- package/src/usage/report.ts +354 -0
- package/src/usage/scan.ts +186 -0
- package/typeclaw.schema.json +134 -98
package/src/cli/hostd.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { defineCommand } from 'citty'
|
|
|
3
3
|
import { loadConfigSync, validateConfig, type Config, type ValidateConfigResult } from '@/config'
|
|
4
4
|
import { start, stop, type StartOptions, type StartResult, type StopResult } from '@/container'
|
|
5
5
|
import { startDaemon, type DaemonLogEvent, type RestartPreflight } from '@/hostd/daemon'
|
|
6
|
+
import { createKakaoRenewalManager } from '@/hostd/kakao-renewal-manager'
|
|
6
7
|
import { createPortbrokerManager } from '@/hostd/portbroker-manager'
|
|
7
8
|
import type { SupervisorLogEvent, SupervisorRestart } from '@/hostd/supervisor'
|
|
8
9
|
import { computeSourceVersion, resolveSrcRoot, UNVERSIONED_SENTINEL } from '@/hostd/version'
|
|
@@ -22,19 +23,35 @@ export const hostdCommand = defineCommand({
|
|
|
22
23
|
onLog: (msg) => writeLogLine(msg),
|
|
23
24
|
})
|
|
24
25
|
|
|
26
|
+
const hostdRestart = buildHostdRestart(cliEntry, defaultRestartDeps, version)
|
|
27
|
+
const kakaoRenewal = createKakaoRenewalManager({
|
|
28
|
+
onLog: (event) => writeLogLine(formatLog(event)),
|
|
29
|
+
onRenewalOk: async ({ containerName, cwd }) => {
|
|
30
|
+
// Restart the container so the in-memory KakaoTalk LOCO client picks
|
|
31
|
+
// up the renewed tokens from secrets.json. Without this, the cron
|
|
32
|
+
// would write fresh tokens but the running adapter would keep using
|
|
33
|
+
// the old token in its closure and still 401 at the ~7-day wall.
|
|
34
|
+
const result = await hostdRestart({ containerName, cwd })
|
|
35
|
+
if (!result.ok) throw new Error(result.reason)
|
|
36
|
+
},
|
|
37
|
+
shouldRenew: ({ cwd }) => kakaoChannelConfigured(cwd),
|
|
38
|
+
})
|
|
39
|
+
|
|
25
40
|
const daemon = await startDaemon({
|
|
26
41
|
onLog: (e) => writeLogLine(formatLog(e)),
|
|
27
42
|
version,
|
|
28
43
|
onShutdown: () => process.exit(0),
|
|
29
44
|
portbroker,
|
|
45
|
+
kakaoRenewal,
|
|
30
46
|
restartPreflight: buildHostdRestartPreflight(cliEntry, version),
|
|
31
|
-
restart:
|
|
47
|
+
restart: hostdRestart,
|
|
32
48
|
})
|
|
33
49
|
|
|
34
50
|
const shutdown = (): void => {
|
|
35
51
|
void daemon
|
|
36
52
|
.stop()
|
|
37
53
|
.then(() => portbroker.drain())
|
|
54
|
+
.then(() => kakaoRenewal.drain())
|
|
38
55
|
.then(() => process.exit(0))
|
|
39
56
|
}
|
|
40
57
|
process.on('SIGTERM', shutdown)
|
|
@@ -135,6 +152,37 @@ function formatLog(event: DaemonLogEvent | SupervisorLogEvent): string {
|
|
|
135
152
|
return formatPortForwardEvent(event.event)
|
|
136
153
|
case 'tailscale-serve-event':
|
|
137
154
|
return formatTailscaleServeEvent(event.event)
|
|
155
|
+
case 'kakao-renewal-tick-start':
|
|
156
|
+
return `[hostd] kakao renewal tick started for ${event.containerName}`
|
|
157
|
+
case 'kakao-renewal-tick-skipped':
|
|
158
|
+
return `[hostd] kakao renewal skipped for ${event.containerName}: ${event.reason}${event.ageMs !== undefined ? ` (age=${Math.round(event.ageMs / 1000 / 60 / 60)}h)` : ''}`
|
|
159
|
+
case 'kakao-renewal-tick-ok':
|
|
160
|
+
return `[hostd] kakao renewal OK for ${event.containerName} account=${event.accountId} (was last updated ${event.previousUpdatedAt})`
|
|
161
|
+
case 'kakao-renewal-tick-reauth-required':
|
|
162
|
+
return `[hostd] kakao renewal REAUTH REQUIRED for ${event.containerName} account=${event.accountId} reason=${event.reason} — ${event.message}`
|
|
163
|
+
case 'kakao-renewal-tick-transient-failure':
|
|
164
|
+
return `[hostd] kakao renewal transient failure for ${event.containerName} account=${event.accountId}: ${event.reason}`
|
|
165
|
+
case 'kakao-renewal-tick-error':
|
|
166
|
+
return `[hostd] kakao renewal ERROR for ${event.containerName}: ${event.error}`
|
|
167
|
+
case 'kakao-renewal-restart-scheduled':
|
|
168
|
+
return `[hostd] kakao renewal scheduled container restart for ${event.containerName} account=${event.accountId}`
|
|
169
|
+
case 'kakao-renewal-restart-failed':
|
|
170
|
+
return `[hostd] kakao renewal container restart FAILED for ${event.containerName} account=${event.accountId}: ${event.reason}`
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Reads the agent's typeclaw.json to decide whether the kakao renewal cron
|
|
175
|
+
// should run for this container. Without this, every typeclaw agent on the
|
|
176
|
+
// host gets a daily `no_account` skip event from the renewal manager — log
|
|
177
|
+
// spam for non-kakao agents. Returns false on read/parse errors so the
|
|
178
|
+
// renewal cron stays silent for agents we can't classify; the kakao adapter
|
|
179
|
+
// itself would surface the real config issue on its next start.
|
|
180
|
+
function kakaoChannelConfigured(cwd: string): boolean {
|
|
181
|
+
try {
|
|
182
|
+
const cfg = loadConfigSync(cwd)
|
|
183
|
+
return cfg.channels?.kakaotalk !== undefined
|
|
184
|
+
} catch {
|
|
185
|
+
return false
|
|
138
186
|
}
|
|
139
187
|
}
|
|
140
188
|
|
package/src/cli/index.ts
CHANGED
|
@@ -23,7 +23,11 @@ const main = defineCommand({
|
|
|
23
23
|
shell: () => import('./shell').then((m) => m.shellCommand),
|
|
24
24
|
compose: () => import('./compose').then((m) => m.composeCommand),
|
|
25
25
|
channel: () => import('./channel').then((m) => m.channelCommand),
|
|
26
|
+
role: () => import('./role').then((m) => m.roleCommand),
|
|
27
|
+
provider: () => import('./provider').then((m) => m.providerCommand),
|
|
28
|
+
model: () => import('./model').then((m) => m.modelCommand),
|
|
26
29
|
doctor: () => import('./doctor').then((m) => m.doctorCommand),
|
|
30
|
+
usage: () => import('./usage').then((m) => m.usageCommand),
|
|
27
31
|
_hostd: () => import('./hostd').then((m) => m.hostdCommand),
|
|
28
32
|
},
|
|
29
33
|
})
|