typeclaw 0.3.1 → 0.5.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 (125) hide show
  1. package/README.md +20 -15
  2. package/auth.schema.json +113 -0
  3. package/package.json +1 -1
  4. package/secrets.schema.json +113 -0
  5. package/src/agent/auth.ts +4 -2
  6. package/src/agent/index.ts +16 -28
  7. package/src/agent/model-fallback.ts +127 -0
  8. package/src/agent/session-meta.ts +1 -1
  9. package/src/agent/session-origin.ts +3 -2
  10. package/src/agent/tools/curl-impersonate.ts +300 -0
  11. package/src/agent/tools/ddg.ts +13 -88
  12. package/src/agent/tools/webfetch/fetch.ts +105 -2
  13. package/src/agent/tools/webfetch/tool.ts +4 -0
  14. package/src/bundled-plugins/agent-browser/shim.ts +47 -0
  15. package/src/bundled-plugins/backup/subagents.ts +2 -0
  16. package/src/bundled-plugins/memory/README.md +49 -12
  17. package/src/bundled-plugins/memory/citation-superset.ts +63 -0
  18. package/src/bundled-plugins/memory/dreaming.ts +105 -17
  19. package/src/bundled-plugins/memory/index.ts +2 -2
  20. package/src/bundled-plugins/memory/memory-logger.ts +45 -26
  21. package/src/bundled-plugins/memory/strength.ts +127 -0
  22. package/src/bundled-plugins/memory/topics.ts +75 -0
  23. package/src/bundled-plugins/security/index.ts +88 -43
  24. package/src/bundled-plugins/security/permissions.ts +36 -0
  25. package/src/bundled-plugins/security/policies/git-exfil.ts +20 -0
  26. package/src/bundled-plugins/security/policies/outbound-secret-scan.ts +12 -0
  27. package/src/bundled-plugins/security/policies/prompt-injection.ts +23 -3
  28. package/src/bundled-plugins/security/policies/secret-exfil-bash.ts +7 -0
  29. package/src/bundled-plugins/security/policies/secret-exfil-read.ts +6 -0
  30. package/src/bundled-plugins/security/policies/session-search-secrets.ts +9 -0
  31. package/src/bundled-plugins/security/policies/ssrf.ts +6 -0
  32. package/src/bundled-plugins/security/policies/system-prompt-leak.ts +7 -0
  33. package/src/channels/adapters/github/auth-app.ts +120 -0
  34. package/src/channels/adapters/github/auth-pat.ts +50 -0
  35. package/src/channels/adapters/github/auth.ts +33 -0
  36. package/src/channels/adapters/github/channel-resolver.ts +30 -0
  37. package/src/channels/adapters/github/dedup.ts +26 -0
  38. package/src/channels/adapters/github/event-allowlist.ts +8 -0
  39. package/src/channels/adapters/github/fetch-attachment.ts +5 -0
  40. package/src/channels/adapters/github/history.ts +63 -0
  41. package/src/channels/adapters/github/inbound.ts +286 -0
  42. package/src/channels/adapters/github/index.ts +370 -0
  43. package/src/channels/adapters/github/managed-path.ts +54 -0
  44. package/src/channels/adapters/github/membership.ts +35 -0
  45. package/src/channels/adapters/github/outbound.ts +145 -0
  46. package/src/channels/adapters/github/webhook-register.ts +349 -0
  47. package/src/channels/manager.ts +94 -9
  48. package/src/channels/router.ts +194 -28
  49. package/src/channels/schema.ts +31 -1
  50. package/src/channels/tunnel-bridge.ts +51 -0
  51. package/src/channels/types.ts +3 -1
  52. package/src/cli/builtins.ts +28 -0
  53. package/src/cli/channel.ts +511 -25
  54. package/src/cli/container-command-client.ts +244 -0
  55. package/src/cli/cron.ts +173 -0
  56. package/src/cli/host-command-runner.ts +150 -0
  57. package/src/cli/index.ts +42 -1
  58. package/src/cli/init.ts +400 -67
  59. package/src/cli/model.ts +14 -4
  60. package/src/cli/oauth-callbacks.ts +49 -0
  61. package/src/cli/plugin-command-help.ts +49 -0
  62. package/src/cli/plugin-commands-dispatch.ts +112 -0
  63. package/src/cli/plugin-commands.ts +118 -0
  64. package/src/cli/provider.ts +3 -20
  65. package/src/cli/tui.ts +10 -2
  66. package/src/cli/tunnel.ts +533 -0
  67. package/src/cli/ui.ts +8 -3
  68. package/src/config/config.ts +134 -24
  69. package/src/config/models-mutation.ts +42 -8
  70. package/src/config/providers-mutation.ts +12 -8
  71. package/src/container/start.ts +48 -4
  72. package/src/cron/bridge.ts +136 -0
  73. package/src/cron/consumer.ts +174 -48
  74. package/src/cron/index.ts +19 -2
  75. package/src/cron/list.ts +105 -0
  76. package/src/cron/scheduler.ts +12 -3
  77. package/src/cron/schema.ts +11 -3
  78. package/src/doctor/checks.ts +0 -50
  79. package/src/init/dockerfile.ts +165 -13
  80. package/src/init/ensure-deps.ts +15 -4
  81. package/src/init/github-webhook-install.ts +109 -0
  82. package/src/init/hatching.ts +2 -2
  83. package/src/init/index.ts +519 -12
  84. package/src/init/oauth-login.ts +17 -3
  85. package/src/init/run-bun-install.ts +17 -3
  86. package/src/init/run-owner-claim.ts +11 -2
  87. package/src/permissions/builtins.ts +29 -2
  88. package/src/permissions/match-rule.ts +24 -2
  89. package/src/permissions/permissions.ts +24 -7
  90. package/src/permissions/resolve.ts +1 -0
  91. package/src/plugin/define.ts +44 -1
  92. package/src/plugin/index.ts +18 -3
  93. package/src/plugin/manager.ts +16 -0
  94. package/src/plugin/registry.ts +85 -3
  95. package/src/plugin/types.ts +144 -1
  96. package/src/plugin/zod-introspect.ts +100 -0
  97. package/src/role-claim/match-rule.ts +2 -1
  98. package/src/run/index.ts +112 -4
  99. package/src/secrets/index.ts +1 -1
  100. package/src/secrets/schema.ts +21 -0
  101. package/src/server/command-runner.ts +476 -0
  102. package/src/server/index.ts +388 -5
  103. package/src/shared/index.ts +8 -0
  104. package/src/shared/protocol.ts +80 -1
  105. package/src/skills/typeclaw-channel-github/SKILL.md +24 -0
  106. package/src/skills/typeclaw-config/SKILL.md +27 -26
  107. package/src/skills/typeclaw-cron/SKILL.md +234 -3
  108. package/src/skills/typeclaw-memory/SKILL.md +25 -15
  109. package/src/skills/typeclaw-monorepo/SKILL.md +2 -2
  110. package/src/skills/typeclaw-permissions/SKILL.md +35 -16
  111. package/src/skills/typeclaw-plugins/SKILL.md +251 -5
  112. package/src/skills/typeclaw-tunnels/SKILL.md +111 -0
  113. package/src/test-helpers/wait-for.ts +50 -0
  114. package/src/tui/index.ts +70 -7
  115. package/src/tunnels/__fixtures__/cloudflared-quick-stderr.txt +11 -0
  116. package/src/tunnels/events.ts +14 -0
  117. package/src/tunnels/index.ts +12 -0
  118. package/src/tunnels/log-ring.ts +54 -0
  119. package/src/tunnels/manager.ts +139 -0
  120. package/src/tunnels/providers/cloudflare-quick.ts +189 -0
  121. package/src/tunnels/providers/external.ts +53 -0
  122. package/src/tunnels/quick-url-parser.ts +5 -0
  123. package/src/tunnels/types.ts +43 -0
  124. package/src/usage/report.ts +15 -12
  125. package/typeclaw.schema.json +311 -26
@@ -145,27 +145,30 @@ function renderOriginLabel(kind: OriginKind, ctx: RenderCtx): string {
145
145
  }
146
146
  }
147
147
 
148
- // Sparkline trend across the full byDay range, scaled to the row's max cost.
149
- // Returns null when there are fewer than 2 days (a single point conveys no
150
- // trend information). The 8-level Unicode block scale `▁▂▃▄▅▆▇█` lets us
151
- // pack ~80 days into a one-line glance wider than any table-based view
152
- // could fit at terminal widths under ~160 columns.
148
+ // Sparkline trend across the full byDay range, scaled to the row's max token
149
+ // count. Tokens (not cost) drive the chart because they're the load-bearing
150
+ // usage signal model price changes and free-tier credits shouldn't flatten
151
+ // or distort the visible workload pattern. Returns null when there are fewer
152
+ // than 2 days (a single point conveys no trend information). The 8-level
153
+ // Unicode block scale `▁▂▃▄▅▆▇█` lets us pack ~80 days into a one-line glance
154
+ // — wider than any table-based view could fit at terminal widths under ~160
155
+ // columns.
153
156
  const SPARK_GLYPHS = '▁▂▃▄▅▆▇█'
154
157
 
155
- function renderDailyTrend(byDay: readonly { date: string; cost: number }[], ctx: RenderCtx): string | null {
158
+ function renderDailyTrend(byDay: readonly { date: string; totalTokens: number }[], ctx: RenderCtx): string | null {
156
159
  if (byDay.length < 2) return null
157
- const costs = byDay.map((d) => d.cost)
158
- const max = costs.reduce((m, c) => Math.max(m, c), 0)
160
+ const tokens = byDay.map((d) => d.totalTokens)
161
+ const max = tokens.reduce((m, t) => Math.max(m, t), 0)
159
162
  if (max <= 0) return null
160
- const spark = costs
161
- .map((c) => {
162
- const idx = Math.min(SPARK_GLYPHS.length - 1, Math.max(0, Math.round((c / max) * (SPARK_GLYPHS.length - 1))))
163
+ const spark = tokens
164
+ .map((t) => {
165
+ const idx = Math.min(SPARK_GLYPHS.length - 1, Math.max(0, Math.round((t / max) * (SPARK_GLYPHS.length - 1))))
163
166
  return SPARK_GLYPHS[idx]!
164
167
  })
165
168
  .join('')
166
169
  const first = byDay[0]!.date
167
170
  const last = byDay[byDay.length - 1]!.date
168
- return `${dim('Trend (cost):', ctx)} ${color('cyan', spark, ctx)} ${dim(`${first} → ${last}`, ctx)}`
171
+ return `${dim('Trend (tokens):', ctx)} ${color('cyan', spark, ctx)} ${dim(`${first} → ${last}`, ctx)}`
169
172
  }
170
173
 
171
174
  function renderDaily(report: UsageReport, ctx: RenderCtx, limit: number | undefined): string {
@@ -12,33 +12,59 @@
12
12
  "maximum": 65535
13
13
  },
14
14
  "models": {
15
- "default": {
16
- "default": "openai/gpt-5.4-nano"
17
- },
18
15
  "type": "object",
19
16
  "propertyNames": {
20
17
  "type": "string",
21
18
  "minLength": 1
22
19
  },
23
20
  "additionalProperties": {
24
- "type": "string",
25
- "enum": [
26
- "openai/gpt-5.4-nano",
27
- "openai/gpt-5.4-mini",
28
- "openai/gpt-5.4",
29
- "openai/gpt-5.5",
30
- "openai-codex/gpt-5.4-mini",
31
- "openai-codex/gpt-5.4",
32
- "openai-codex/gpt-5.5",
33
- "fireworks/accounts/fireworks/routers/kimi-k2p6-turbo",
34
- "zai/glm-4.5-air",
35
- "zai/glm-4.6",
36
- "zai/glm-4.7",
37
- "zai-coding/glm-4.5-air",
38
- "zai-coding/glm-4.7",
39
- "zai-coding/glm-5",
40
- "zai-coding/glm-5-turbo",
41
- "zai-coding/glm-5.1"
21
+ "anyOf": [
22
+ {
23
+ "type": "string",
24
+ "enum": [
25
+ "openai/gpt-5.4-nano",
26
+ "openai/gpt-5.4-mini",
27
+ "openai/gpt-5.4",
28
+ "openai/gpt-5.5",
29
+ "openai-codex/gpt-5.4-mini",
30
+ "openai-codex/gpt-5.4",
31
+ "openai-codex/gpt-5.5",
32
+ "fireworks/accounts/fireworks/routers/kimi-k2p6-turbo",
33
+ "zai/glm-4.5-air",
34
+ "zai/glm-4.6",
35
+ "zai/glm-4.7",
36
+ "zai-coding/glm-4.5-air",
37
+ "zai-coding/glm-4.7",
38
+ "zai-coding/glm-5",
39
+ "zai-coding/glm-5-turbo",
40
+ "zai-coding/glm-5.1"
41
+ ]
42
+ },
43
+ {
44
+ "minItems": 1,
45
+ "type": "array",
46
+ "items": {
47
+ "type": "string",
48
+ "enum": [
49
+ "openai/gpt-5.4-nano",
50
+ "openai/gpt-5.4-mini",
51
+ "openai/gpt-5.4",
52
+ "openai/gpt-5.5",
53
+ "openai-codex/gpt-5.4-mini",
54
+ "openai-codex/gpt-5.4",
55
+ "openai-codex/gpt-5.5",
56
+ "fireworks/accounts/fireworks/routers/kimi-k2p6-turbo",
57
+ "zai/glm-4.5-air",
58
+ "zai/glm-4.6",
59
+ "zai/glm-4.7",
60
+ "zai-coding/glm-4.5-air",
61
+ "zai-coding/glm-4.7",
62
+ "zai-coding/glm-5",
63
+ "zai-coding/glm-5-turbo",
64
+ "zai-coding/glm-5.1"
65
+ ]
66
+ }
67
+ }
42
68
  ]
43
69
  }
44
70
  },
@@ -231,6 +257,179 @@
231
257
  }
232
258
  }
233
259
  },
260
+ "github": {
261
+ "type": "object",
262
+ "properties": {
263
+ "engagement": {
264
+ "default": {
265
+ "trigger": [
266
+ "mention",
267
+ "reply",
268
+ "dm"
269
+ ],
270
+ "stickiness": {
271
+ "perReply": {
272
+ "window": 300000
273
+ }
274
+ }
275
+ },
276
+ "type": "object",
277
+ "properties": {
278
+ "trigger": {
279
+ "default": [
280
+ "mention",
281
+ "reply",
282
+ "dm"
283
+ ],
284
+ "type": "array",
285
+ "items": {
286
+ "type": "string",
287
+ "enum": [
288
+ "mention",
289
+ "reply",
290
+ "dm"
291
+ ]
292
+ }
293
+ },
294
+ "stickiness": {
295
+ "default": {
296
+ "perReply": {
297
+ "window": 300000
298
+ }
299
+ },
300
+ "anyOf": [
301
+ {
302
+ "type": "string",
303
+ "const": "off"
304
+ },
305
+ {
306
+ "type": "object",
307
+ "properties": {
308
+ "perReply": {
309
+ "type": "object",
310
+ "properties": {
311
+ "window": {
312
+ "type": "integer",
313
+ "minimum": 1,
314
+ "maximum": 86400000
315
+ }
316
+ },
317
+ "required": [
318
+ "window"
319
+ ]
320
+ }
321
+ },
322
+ "required": [
323
+ "perReply"
324
+ ]
325
+ }
326
+ ]
327
+ }
328
+ }
329
+ },
330
+ "history": {
331
+ "default": {
332
+ "prefetch": {
333
+ "thread": {
334
+ "head": 3,
335
+ "tail": 10
336
+ },
337
+ "channel": {
338
+ "tail": 10
339
+ }
340
+ }
341
+ },
342
+ "type": "object",
343
+ "properties": {
344
+ "prefetch": {
345
+ "default": {
346
+ "thread": {
347
+ "head": 3,
348
+ "tail": 10
349
+ },
350
+ "channel": {
351
+ "tail": 10
352
+ }
353
+ },
354
+ "type": "object",
355
+ "properties": {
356
+ "thread": {
357
+ "default": {
358
+ "head": 3,
359
+ "tail": 10
360
+ },
361
+ "type": "object",
362
+ "properties": {
363
+ "head": {
364
+ "default": 3,
365
+ "type": "integer",
366
+ "minimum": 0,
367
+ "maximum": 200
368
+ },
369
+ "tail": {
370
+ "default": 10,
371
+ "type": "integer",
372
+ "minimum": 0,
373
+ "maximum": 200
374
+ }
375
+ }
376
+ },
377
+ "channel": {
378
+ "default": {
379
+ "tail": 10
380
+ },
381
+ "type": "object",
382
+ "properties": {
383
+ "tail": {
384
+ "default": 10,
385
+ "type": "integer",
386
+ "minimum": 0,
387
+ "maximum": 200
388
+ }
389
+ }
390
+ }
391
+ }
392
+ }
393
+ }
394
+ },
395
+ "enabled": {
396
+ "default": true,
397
+ "type": "boolean"
398
+ },
399
+ "webhookUrl": {
400
+ "type": "string",
401
+ "format": "uri"
402
+ },
403
+ "webhookPort": {
404
+ "default": 8975,
405
+ "type": "integer",
406
+ "exclusiveMinimum": 0,
407
+ "maximum": 9007199254740991
408
+ },
409
+ "eventAllowlist": {
410
+ "default": [
411
+ "issue_comment.created",
412
+ "pull_request_review_comment.created",
413
+ "discussion_comment.created",
414
+ "issues.opened",
415
+ "pull_request.opened",
416
+ "discussion.created",
417
+ "pull_request_review.submitted"
418
+ ],
419
+ "type": "array",
420
+ "items": {
421
+ "type": "string"
422
+ }
423
+ },
424
+ "repos": {
425
+ "default": [],
426
+ "type": "array",
427
+ "items": {
428
+ "type": "string"
429
+ }
430
+ }
431
+ }
432
+ },
234
433
  "kakaotalk": {
235
434
  "type": "object",
236
435
  "properties": {
@@ -723,6 +922,9 @@
723
922
  "gh": true,
724
923
  "python": true,
725
924
  "tmux": true,
925
+ "cjkFonts": true,
926
+ "cloudflared": true,
927
+ "xvfb": true,
726
928
  "append": []
727
929
  }
728
930
  },
@@ -734,6 +936,9 @@
734
936
  "gh": true,
735
937
  "python": true,
736
938
  "tmux": true,
939
+ "cjkFonts": true,
940
+ "cloudflared": true,
941
+ "xvfb": true,
737
942
  "append": []
738
943
  },
739
944
  "type": "object",
@@ -778,6 +983,18 @@
778
983
  }
779
984
  ]
780
985
  },
986
+ "cjkFonts": {
987
+ "default": true,
988
+ "type": "boolean"
989
+ },
990
+ "cloudflared": {
991
+ "default": true,
992
+ "type": "boolean"
993
+ },
994
+ "xvfb": {
995
+ "default": true,
996
+ "type": "boolean"
997
+ },
781
998
  "append": {
782
999
  "default": [],
783
1000
  "type": "array",
@@ -826,7 +1043,7 @@
826
1043
  "type": "array",
827
1044
  "items": {
828
1045
  "type": "string",
829
- "pattern": "^(tui|cron|subagent(:[a-z][a-z0-9-]*)?|\\*|(slack|discord|telegram|kakao):[^\\s]+)(\\s+[a-zA-Z][a-zA-Z0-9_]*:[^\\s]+)*$"
1046
+ "pattern": "^(tui|cron|subagent(:[a-z][a-z0-9-]*)?|\\*|(slack|discord|telegram|kakao|github):[^\\s]+)(\\s+[a-zA-Z][a-zA-Z0-9_]*:[^\\s]+)*$"
830
1047
  }
831
1048
  },
832
1049
  "permissions": {
@@ -841,6 +1058,74 @@
841
1058
  "additionalProperties": false
842
1059
  }
843
1060
  },
1061
+ "tunnels": {
1062
+ "default": [],
1063
+ "type": "array",
1064
+ "items": {
1065
+ "type": "object",
1066
+ "properties": {
1067
+ "name": {
1068
+ "type": "string",
1069
+ "minLength": 1,
1070
+ "pattern": "^[a-z0-9][a-z0-9-_]*$"
1071
+ },
1072
+ "provider": {
1073
+ "type": "string",
1074
+ "enum": [
1075
+ "external",
1076
+ "cloudflare-quick"
1077
+ ]
1078
+ },
1079
+ "for": {
1080
+ "oneOf": [
1081
+ {
1082
+ "type": "object",
1083
+ "properties": {
1084
+ "kind": {
1085
+ "type": "string",
1086
+ "const": "channel"
1087
+ },
1088
+ "name": {
1089
+ "type": "string",
1090
+ "minLength": 1
1091
+ }
1092
+ },
1093
+ "required": [
1094
+ "kind",
1095
+ "name"
1096
+ ]
1097
+ },
1098
+ {
1099
+ "type": "object",
1100
+ "properties": {
1101
+ "kind": {
1102
+ "type": "string",
1103
+ "const": "manual"
1104
+ }
1105
+ },
1106
+ "required": [
1107
+ "kind"
1108
+ ]
1109
+ }
1110
+ ]
1111
+ },
1112
+ "externalUrl": {
1113
+ "type": "string",
1114
+ "format": "uri"
1115
+ },
1116
+ "upstreamPort": {
1117
+ "type": "integer",
1118
+ "minimum": 1,
1119
+ "maximum": 65535
1120
+ }
1121
+ },
1122
+ "required": [
1123
+ "name",
1124
+ "provider",
1125
+ "for"
1126
+ ]
1127
+ }
1128
+ },
844
1129
  "tool-result-cap": {
845
1130
  "default": {
846
1131
  "enabled": true,
@@ -877,20 +1162,20 @@
877
1162
  },
878
1163
  "memory": {
879
1164
  "default": {
880
- "idleMs": 10000,
881
- "bufferBytes": 100000,
1165
+ "idleMs": 60000,
1166
+ "bufferBytes": 500000,
882
1167
  "spawnTimeoutMs": 50000
883
1168
  },
884
1169
  "type": "object",
885
1170
  "properties": {
886
1171
  "idleMs": {
887
- "default": 10000,
1172
+ "default": 60000,
888
1173
  "type": "integer",
889
1174
  "minimum": 1000,
890
1175
  "maximum": 9007199254740991
891
1176
  },
892
1177
  "bufferBytes": {
893
- "default": 100000,
1178
+ "default": 500000,
894
1179
  "type": "integer",
895
1180
  "minimum": 0,
896
1181
  "maximum": 9007199254740991