cortico 0.1.0 → 0.1.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.
Files changed (112) hide show
  1. package/README.md +7 -14
  2. package/package.json +1 -3
  3. package/src/boot.ts +18 -0
  4. package/src/bot.ts +41 -6
  5. package/src/core/README.md +4 -6
  6. package/src/core/blobs.ts +23 -2
  7. package/src/core/config-schema.ts +1 -1
  8. package/src/core/config.ts +2 -16
  9. package/src/core/core.ts +15 -5
  10. package/src/core/loop.ts +55 -27
  11. package/src/core/session.ts +3 -2
  12. package/src/core/timers.ts +8 -6
  13. package/src/core/types.ts +19 -3
  14. package/src/core/util.ts +17 -1
  15. package/src/deploy.ts +4 -1
  16. package/src/extensions/README.md +6 -4
  17. package/src/extensions/dry-mount.ts +23 -2
  18. package/src/extensions/manifest.ts +21 -11
  19. package/src/extensions.ts +147 -23
  20. package/src/launcher.ts +23 -9
  21. package/src/protocol/open-responses/context-log.ts +37 -9
  22. package/src/providers/README.md +32 -8
  23. package/src/providers/base.ts +3 -1
  24. package/src/providers/configuration.ts +2 -1
  25. package/src/providers/console/hub.ts +270 -0
  26. package/src/providers/console/settings.ts +8 -18
  27. package/src/providers/console/types.ts +5 -0
  28. package/src/providers/hub-api.ts +3 -0
  29. package/src/providers/llamacpp/config.ts +8 -6
  30. package/src/providers/llamacpp/console/runtime-panel.ts +5 -1
  31. package/src/providers/llamacpp/console/server.ts +3 -1
  32. package/src/providers/llamacpp/index.ts +3 -1
  33. package/src/providers/llamacpp/native.ts +10 -5
  34. package/src/providers/llamacpp/strings.ts +6 -6
  35. package/src/providers/name.ts +8 -0
  36. package/src/providers/openai-responses-compat/config.ts +13 -0
  37. package/src/providers/openai-responses-compat/console/client.ts +5 -0
  38. package/src/providers/openai-responses-compat/console/reasoning-panel.ts +84 -0
  39. package/src/providers/openai-responses-compat/console/server.ts +127 -0
  40. package/src/providers/openai-responses-compat/index.ts +38 -13
  41. package/src/providers/openai-responses-compat/native.ts +9 -4
  42. package/src/providers/openai-responses-compat/strings.ts +62 -1
  43. package/src/providers/registry.ts +5 -0
  44. package/src/providers/transport/responses-input.ts +59 -10
  45. package/src/web/README.md +11 -6
  46. package/src/web/auth.ts +80 -0
  47. package/src/web/client/console-pages/builtins/llm-settings/panel.ts +5 -4
  48. package/src/web/client/console-pages/builtins/llm-settings/pricing-panel.ts +22 -8
  49. package/src/web/client/console-pages/builtins/llm-settings/strings.ts +6 -8
  50. package/src/web/client/console-pages/host.ts +24 -7
  51. package/src/web/client/core/api.ts +5 -1
  52. package/src/web/client/core/router.ts +15 -0
  53. package/src/web/client/features/core/strings.ts +2 -2
  54. package/src/web/client/features/extensions/index.ts +276 -41
  55. package/src/web/client/features/extensions/strings.ts +84 -10
  56. package/src/web/client/features/feature.ts +2 -2
  57. package/src/web/client/features/live/diagnostics.ts +32 -0
  58. package/src/web/client/features/live/index.ts +34 -11
  59. package/src/web/client/features/live/onboarding.ts +4 -1
  60. package/src/web/client/features/live/protocol.ts +1 -0
  61. package/src/web/client/features/live/strings.ts +20 -14
  62. package/src/web/client/features/live/timeline.ts +2 -1
  63. package/src/web/client/features/providers/detail.ts +262 -0
  64. package/src/web/client/features/providers/drafts.ts +23 -0
  65. package/src/web/client/features/providers/index.ts +173 -87
  66. package/src/web/client/features/providers/strings.ts +44 -17
  67. package/src/web/client/features/providers/types.ts +15 -0
  68. package/src/web/client/features/settings/general.ts +13 -0
  69. package/src/web/client/features/settings/index.ts +1 -0
  70. package/src/web/client/features/settings/strings.ts +6 -0
  71. package/src/web/client/features/worlds/index.ts +1 -0
  72. package/src/web/client/main.ts +4 -0
  73. package/src/web/client/shell/index.ts +28 -48
  74. package/src/web/client/shell/strings.ts +0 -22
  75. package/src/web/client/ui/icons.ts +14 -1
  76. package/src/web/client/ui/prompt-input.tsx +17 -5
  77. package/src/web/client/ui/strings.ts +0 -2
  78. package/src/web/console-pages.ts +1 -1
  79. package/src/web/diagnostics.ts +133 -0
  80. package/src/web/public/login.html +67 -0
  81. package/src/web/public/styles.css +143 -26
  82. package/src/web/server.ts +233 -19
  83. package/src/web/shared/client-panel.ts +4 -1
  84. package/src/web/shared/console-protocol.ts +4 -1
  85. package/src/worlds/bilibili/README.md +1 -1
  86. package/src/worlds/bilibili/overlay/server.ts +4 -2
  87. package/src/worlds/minecraft/ADAPT.md +66 -0
  88. package/src/worlds/minecraft/README.md +69 -11
  89. package/src/worlds/minecraft/cell-facts.ts +226 -0
  90. package/src/worlds/minecraft/chests.ts +5 -0
  91. package/src/worlds/minecraft/containers.ts +325 -0
  92. package/src/worlds/minecraft/entity-facts.ts +31 -5
  93. package/src/worlds/minecraft/executor.ts +283 -10348
  94. package/src/worlds/minecraft/inventory.ts +268 -0
  95. package/src/worlds/minecraft/melee.ts +419 -0
  96. package/src/worlds/minecraft/mineflayer-fixes.ts +55 -1
  97. package/src/worlds/minecraft/placed-ledger.ts +152 -0
  98. package/src/worlds/minecraft/placement.ts +1038 -0
  99. package/src/worlds/minecraft/receipt.ts +340 -0
  100. package/src/worlds/minecraft/skill-context.ts +358 -0
  101. package/src/worlds/minecraft/skills-build.ts +1169 -0
  102. package/src/worlds/minecraft/skills-container.ts +1343 -0
  103. package/src/worlds/minecraft/skills-craft.ts +333 -0
  104. package/src/worlds/minecraft/skills-dig.ts +624 -0
  105. package/src/worlds/minecraft/skills-gather.ts +1230 -0
  106. package/src/worlds/minecraft/skills-interact.ts +1559 -0
  107. package/src/worlds/minecraft/tools.ts +331 -0
  108. package/src/worlds/minecraft/travel.ts +763 -0
  109. package/src/worlds/minecraft/until.ts +75 -0
  110. package/src/worlds/qq/normalize.ts +14 -0
  111. package/src/worlds/qq/world.ts +53 -7
  112. package/src/worlds/terminal/world.ts +5 -3
@@ -1,13 +1,16 @@
1
1
  /** 实体元数据字段位置取自 registry.entitiesByName 的 metadataKeys。 */
2
+ import type { Bot } from 'mineflayer';
3
+ import { matchBlockIds } from './travel.ts';
4
+ import { zhName } from './names.ts';
2
5
 
3
- interface NamedStack { name?: string }
6
+ export interface NamedStack { name?: string }
4
7
 
5
- interface FactEntity {
8
+ export interface FactEntity {
6
9
  name?: string;
7
10
  metadata?: unknown[];
8
11
  }
9
12
 
10
- interface FactBot {
13
+ export interface FactBot {
11
14
  entity?: { uuid?: string } | null;
12
15
  /** 登录时玩家 UUID 优先取 bot.player,其次取实体或协议客户端。 */
13
16
  player?: { uuid?: string } | null;
@@ -18,7 +21,7 @@ interface FactBot {
18
21
  };
19
22
  }
20
23
 
21
- function metaOf(bot: FactBot, entity: FactEntity, key: string): unknown {
24
+ export function metaOf(bot: FactBot, entity: FactEntity, key: string): unknown {
22
25
  const name = entity.name;
23
26
  if (!name) return undefined;
24
27
  const keys = bot.registry?.entitiesByName?.[name]?.metadataKeys ?? [];
@@ -112,7 +115,7 @@ export function readHorseTamed(bot: FactBot, entity: FactEntity): boolean | null
112
115
  }
113
116
 
114
117
  /** 羊毛元数据的低四位是颜色,第五位(0x10)是"剪过了"。 */
115
- const WOOL_COLORS = [
118
+ export const WOOL_COLORS = [
116
119
  'white', 'orange', 'magenta', 'light_blue', 'yellow', 'lime', 'pink', 'gray',
117
120
  'light_gray', 'cyan', 'purple', 'blue', 'brown', 'green', 'red', 'black',
118
121
  ] as const;
@@ -130,3 +133,26 @@ export function readSheepColor(bot: FactBot, entity: FactEntity): string | null
130
133
  if (typeof raw !== 'number') return null;
131
134
  return WOOL_COLORS[raw & 0x0f] ?? null;
132
135
  }
136
+ /** 可攻击目标名限定为实体类型 ID 或在线玩家名。 */
137
+ /** use.target 只接受活物;无效目标的回执说明可接受类型及改用 at 的方块写法。 */
138
+ export function unknownUseTargetText(bot: Bot, target: string): string {
139
+ const head = `use 的 target 只认活物(生物、玩家),「${target}」不是活物`;
140
+ const ids = matchBlockIds(bot, target);
141
+ if (ids.length === 0) return `${head};要右键一格方块的话写 {"skill":"use","at":[x,y,z]}`;
142
+ // 现场恰好找得到那一格就把坐标一并给出:她照抄就能用
143
+ const near = bot.findBlocks({ matching: ids, maxDistance: 16, count: 1 })[0] ?? null;
144
+ if (!near) {
145
+ return `${head},它是方块 —— 右键方块写 {"skill":"use","at":[x,y,z]};` +
146
+ `那一格在哪先用 {"skill":"find","target":"${target}","distance":16} 问一句`;
147
+ }
148
+ return `${head},它是方块 —— 右键它写 {"skill":"use","at":[${near.x},${near.y},${near.z}]}` +
149
+ `(${zhName(target)}就在那一格,16 格内看得见的最近一处)`;
150
+ }
151
+
152
+ export function isKnownTarget(bot: Bot, name: string): boolean {
153
+ const n = name.toLowerCase();
154
+ const entities = (bot.registry as unknown as { entitiesByName?: Record<string, unknown> }).entitiesByName;
155
+ if (entities?.[n]) return true;
156
+ return Object.keys(bot.players ?? {}).some((p) => p.toLowerCase() === n);
157
+ }
158
+