typeclaw 0.47.1 → 0.48.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.
Files changed (113) hide show
  1. package/package.json +1 -1
  2. package/src/agent/index.ts +1 -2
  3. package/src/agent/loop-guard.ts +71 -41
  4. package/src/agent/plugin-tools.ts +167 -50
  5. package/src/agent/retry-same-ref.ts +89 -9
  6. package/src/agent/subagents.ts +88 -15
  7. package/src/agent/system-prompt.ts +1 -1
  8. package/src/agent/turn-runner.ts +60 -5
  9. package/src/bundled-plugins/agent-browser/index.ts +0 -35
  10. package/src/bundled-plugins/agent-browser/skills/agent-browser/SKILL.md +1 -1
  11. package/src/bundled-plugins/guard/policies/non-workspace-write.ts +16 -1
  12. package/src/bundled-plugins/memory/append-tool.ts +75 -2
  13. package/src/bundled-plugins/memory/frontmatter.ts +13 -2
  14. package/src/bundled-plugins/memory/load-memory.ts +1 -1
  15. package/src/bundled-plugins/memory/memory-logger.ts +5 -1
  16. package/src/bundled-plugins/memory/secret-detector.ts +7 -0
  17. package/src/bundled-plugins/memory/vector/hybrid.ts +3 -1
  18. package/src/bundled-plugins/memory/vector/passages.ts +5 -1
  19. package/src/bundled-plugins/operator/operator.ts +9 -2
  20. package/src/bundled-plugins/researcher/researcher.ts +4 -6
  21. package/src/bundled-plugins/security/index.ts +148 -98
  22. package/src/bundled-plugins/security/policies/private-surface-read.ts +43 -28
  23. package/src/channels/adapters/discord-bot-edit.ts +3 -5
  24. package/src/channels/adapters/discord-bot-reactions.ts +4 -6
  25. package/src/channels/adapters/discord-bot-slash-commands.ts +3 -1
  26. package/src/channels/adapters/discord-bot.ts +20 -23
  27. package/src/channels/adapters/discord-edit.ts +3 -5
  28. package/src/channels/adapters/discord-reactions.ts +4 -6
  29. package/src/channels/adapters/discord.ts +1 -1
  30. package/src/channels/adapters/github/decoy-reviewer.ts +2 -1
  31. package/src/channels/adapters/github/history.ts +2 -1
  32. package/src/channels/adapters/github/inbound.ts +4 -11
  33. package/src/channels/adapters/github/index.ts +6 -9
  34. package/src/channels/adapters/github/outbound.ts +3 -6
  35. package/src/channels/adapters/github/reactions.ts +3 -2
  36. package/src/channels/adapters/github/reconcile-cooldown-store.ts +4 -6
  37. package/src/channels/adapters/github/reconcile-open-prs.ts +5 -4
  38. package/src/channels/adapters/github/recover-failed-deliveries.ts +2 -5
  39. package/src/channels/adapters/github/review-state.ts +3 -2
  40. package/src/channels/adapters/github/review-thread-resolver.ts +3 -2
  41. package/src/channels/adapters/github/webhook-register.ts +5 -8
  42. package/src/channels/adapters/instagram-channel-resolver.ts +3 -5
  43. package/src/channels/adapters/instagram.ts +1 -1
  44. package/src/channels/adapters/kakaotalk-author-resolver.ts +2 -5
  45. package/src/channels/adapters/kakaotalk-channel-resolver.ts +3 -5
  46. package/src/channels/adapters/kakaotalk-fetch-attachment.ts +2 -1
  47. package/src/channels/adapters/kakaotalk-membership.ts +2 -5
  48. package/src/channels/adapters/kakaotalk-typing.ts +1 -1
  49. package/src/channels/adapters/kakaotalk.ts +1 -1
  50. package/src/channels/adapters/line-channel-resolver.ts +3 -5
  51. package/src/channels/adapters/line.ts +1 -1
  52. package/src/channels/adapters/slack-bot-edit.ts +1 -1
  53. package/src/channels/adapters/slack-bot-reactions.ts +4 -6
  54. package/src/channels/adapters/slack-bot.ts +8 -8
  55. package/src/channels/adapters/slack-edit.ts +3 -5
  56. package/src/channels/adapters/slack-reactions.ts +4 -6
  57. package/src/channels/adapters/slack.ts +1 -1
  58. package/src/channels/adapters/teams-edit.ts +2 -5
  59. package/src/channels/adapters/teams.ts +1 -1
  60. package/src/channels/adapters/telegram-bot-edit.ts +4 -7
  61. package/src/channels/adapters/telegram-bot.ts +1 -1
  62. package/src/channels/adapters/webex-bot.ts +1 -1
  63. package/src/channels/adapters/webex-edit.ts +3 -5
  64. package/src/channels/adapters/webex.ts +1 -1
  65. package/src/channels/github-review-claim.ts +89 -4
  66. package/src/channels/github-token-bridge.ts +2 -1
  67. package/src/channels/manager.ts +478 -64
  68. package/src/channels/membership-cache.ts +2 -5
  69. package/src/channels/persistence.ts +3 -6
  70. package/src/channels/reloadable.ts +23 -6
  71. package/src/channels/router.ts +134 -56
  72. package/src/channels/tunnel-bridge.ts +2 -1
  73. package/src/channels/types.ts +6 -3
  74. package/src/cli/hostd.ts +56 -28
  75. package/src/config/config.ts +10 -0
  76. package/src/config/providers.ts +179 -0
  77. package/src/dependencies/bin-resolver.ts +88 -0
  78. package/src/dependencies/bins.ts +227 -0
  79. package/src/dependencies/index.ts +17 -0
  80. package/src/doctor/checks.ts +2 -0
  81. package/src/doctor/operational-incidents.ts +32 -0
  82. package/src/hostd/credential-rotation-apply.ts +94 -0
  83. package/src/init/dockerfile.ts +36 -18
  84. package/src/init/index.ts +1 -1
  85. package/src/init/models-dev.ts +17 -3
  86. package/src/init/validate-api-key.ts +26 -4
  87. package/src/operations/classify-tool-outcome.ts +151 -0
  88. package/src/operations/incidents.ts +274 -0
  89. package/src/operations/index.ts +3 -0
  90. package/src/operations/remediations.ts +41 -0
  91. package/src/reload/client.ts +8 -2
  92. package/src/reload/docker-exec-client.ts +10 -2
  93. package/src/reload/index.ts +1 -1
  94. package/src/reload/recover.ts +5 -3
  95. package/src/reload/registry.ts +5 -5
  96. package/src/reload/types.ts +9 -1
  97. package/src/run/index.ts +5 -0
  98. package/src/sandbox/dependency-bins.ts +125 -0
  99. package/src/sandbox/errors.ts +32 -0
  100. package/src/sandbox/hidden-paths.ts +4 -1
  101. package/src/sandbox/index.ts +8 -0
  102. package/src/sandbox/policy.ts +1 -1
  103. package/src/sandbox/privileged-runtime.ts +88 -7
  104. package/src/sandbox/runtime-private.ts +4 -0
  105. package/src/sandbox/writable-zones.ts +4 -4
  106. package/src/server/index.ts +7 -5
  107. package/src/shared/protocol.ts +6 -1
  108. package/src/skills/typeclaw-monorepo/SKILL.md +1 -1
  109. package/src/skills/typeclaw-troubleshooting/SKILL.md +1 -1
  110. package/typeclaw.schema.json +35 -5
  111. package/src/bundled-plugins/agent-browser/shim-install.ts +0 -158
  112. package/src/bundled-plugins/agent-browser/shim.ts +0 -108
  113. /package/src/channels/{adapters/describe-error.ts → describe-error.ts} +0 -0
@@ -1,3 +1,4 @@
1
+ import { describeError } from './describe-error'
1
2
  import {
2
3
  MEMBERSHIP_CACHE_PERMANENT_TTL_MS,
3
4
  MEMBERSHIP_CACHE_TRANSIENT_TTL_MS,
@@ -76,7 +77,7 @@ export function createMembershipCache(options: MembershipCacheOptions): Membersh
76
77
  try {
77
78
  result = await options.resolver(key)
78
79
  } catch (err) {
79
- options.logger?.warn(`[channels] membership resolver threw for ${keyId}: ${describe(err)}`)
80
+ options.logger?.warn(`[channels] membership resolver threw for ${keyId}: ${describeError(err)}`)
80
81
  result = { kind: 'transient' }
81
82
  }
82
83
  entries.set(keyId, { result, expiresAt: now() + ttlFor(result), servedStale: false })
@@ -109,8 +110,4 @@ function isMembershipCount(result: MembershipResolverResult): result is Membersh
109
110
  return 'humans' in result
110
111
  }
111
112
 
112
- function describe(err: unknown): string {
113
- return err instanceof Error ? err.message : String(err)
114
- }
115
-
116
113
  export type { MembershipResolverFailure }
@@ -4,6 +4,7 @@ import { dirname, join } from 'node:path'
4
4
  import type { ChannelParticipant } from '@/agent/session-origin'
5
5
 
6
6
  import { toRef } from './adapters/webex-id-ref'
7
+ import { describeError } from './describe-error'
7
8
  import type { AdapterId } from './schema'
8
9
  import type { ChannelKey } from './types'
9
10
 
@@ -71,7 +72,7 @@ export async function loadChannelSessions(
71
72
  try {
72
73
  parsed = JSON.parse(raw)
73
74
  } catch (err) {
74
- logger.error(`[channels] ${path} corrupted: ${describe(err)}; starting fresh`)
75
+ logger.error(`[channels] ${path} corrupted: ${describeError(err)}; starting fresh`)
75
76
  return []
76
77
  }
77
78
  if (!isObject(parsed)) {
@@ -107,7 +108,7 @@ export async function saveChannelSessions(
107
108
  const { rename } = await import('node:fs/promises')
108
109
  await rename(tmp, path)
109
110
  } catch (err) {
110
- logger.error(`[channels] failed to persist sessions: ${describe(err)}`)
111
+ logger.error(`[channels] failed to persist sessions: ${describeError(err)}`)
111
112
  }
112
113
  }
113
114
 
@@ -201,7 +202,3 @@ function isValidRecord(v: unknown): v is ChannelSessionRecord {
201
202
  Array.isArray(r.participants)
202
203
  )
203
204
  }
204
-
205
- function describe(err: unknown): string {
206
- return err instanceof Error ? err.message : String(err)
207
- }
@@ -1,28 +1,45 @@
1
- import type { Reloadable, ReloadResult } from '@/reload'
1
+ import type { Reloadable, ReloadContext, ReloadResult } from '@/reload'
2
2
 
3
- import type { ChannelManager } from './manager'
3
+ import { describeError } from './describe-error'
4
+ import type { ChannelManager, ChannelReloadOptions } from './manager'
5
+ import { ADAPTER_IDS, type AdapterId } from './schema'
4
6
 
5
7
  export type CreateChannelsReloadableOptions = {
6
- manager: ChannelManager
8
+ manager: Pick<ChannelManager, 'reload'>
7
9
  }
8
10
 
9
11
  export function createChannelsReloadable({ manager }: CreateChannelsReloadableOptions): Reloadable {
10
12
  return {
11
13
  scope: 'channels',
12
14
  description: 'channels adapters and live config',
13
- reload: async (): Promise<ReloadResult> => {
15
+ reload: async (context?: ReloadContext): Promise<ReloadResult> => {
14
16
  try {
15
- const diff = await manager.reload()
17
+ const diff = await manager.reload(toReloadOptions(context))
16
18
  const parts: string[] = []
17
19
  if (diff.started.length > 0) parts.push(`${diff.started.length} started`)
18
20
  if (diff.stopped.length > 0) parts.push(`${diff.stopped.length} stopped`)
21
+ if (diff.restarted.length > 0) parts.push(`${diff.restarted.length} restarted`)
19
22
  if (diff.restartRequired.length > 0) parts.push(`${diff.restartRequired.length} restart-required`)
20
23
  const summary = parts.length === 0 ? 'no adapter changes' : parts.join(', ')
21
24
  return { scope: 'channels', ok: true, summary, details: diff }
22
25
  } catch (err) {
23
- const message = err instanceof Error ? err.message : String(err)
26
+ const message = describeError(err)
24
27
  return { scope: 'channels', ok: false, reason: message }
25
28
  }
26
29
  },
27
30
  }
28
31
  }
32
+
33
+ // The cause arrives off the wire, so the adapter name is an unvalidated string.
34
+ // Dropping an unrecognized one keeps reload non-destructive by default: the
35
+ // worst case is a rotation reported instead of applied, never a bounce of an
36
+ // adapter the caller did not name.
37
+ function toReloadOptions(context: ReloadContext | undefined): ChannelReloadOptions {
38
+ const cause = context?.cause
39
+ if (cause?.kind !== 'credential-rotation') return {}
40
+ return isAdapterId(cause.adapter) ? { applyCredentialRotation: cause.adapter } : {}
41
+ }
42
+
43
+ function isAdapterId(value: string): value is AdapterId {
44
+ return (ADAPTER_IDS as readonly string[]).includes(value)
45
+ }