@hoplogic/hopjit 0.1.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 (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +99 -0
  3. package/dist/act-body-interpreter.d.ts +24 -0
  4. package/dist/act-body-interpreter.js +159 -0
  5. package/dist/act-body-parser.d.ts +10 -0
  6. package/dist/act-body-parser.js +577 -0
  7. package/dist/act-builtins.d.ts +12 -0
  8. package/dist/act-builtins.js +104 -0
  9. package/dist/ast-helpers.d.ts +26 -0
  10. package/dist/ast-helpers.js +58 -0
  11. package/dist/ast-runtime.d.ts +49 -0
  12. package/dist/ast-runtime.js +224 -0
  13. package/dist/ast-types.d.ts +260 -0
  14. package/dist/ast-types.js +4 -0
  15. package/dist/cli-types.d.ts +190 -0
  16. package/dist/cli-types.js +4 -0
  17. package/dist/cli.d.ts +26 -0
  18. package/dist/cli.js +623 -0
  19. package/dist/dispatcher.d.ts +92 -0
  20. package/dist/dispatcher.js +692 -0
  21. package/dist/doc-ref.d.ts +41 -0
  22. package/dist/doc-ref.js +214 -0
  23. package/dist/engine-traverse.d.ts +37 -0
  24. package/dist/engine-traverse.js +385 -0
  25. package/dist/engine.d.ts +141 -0
  26. package/dist/engine.js +1792 -0
  27. package/dist/errors.d.ts +47 -0
  28. package/dist/errors.js +34 -0
  29. package/dist/hoplog.d.ts +120 -0
  30. package/dist/hoplog.js +501 -0
  31. package/dist/parser.d.ts +7 -0
  32. package/dist/parser.js +802 -0
  33. package/dist/persistence.d.ts +60 -0
  34. package/dist/persistence.js +208 -0
  35. package/dist/prompt.d.ts +130 -0
  36. package/dist/prompt.js +1014 -0
  37. package/dist/provider-types.d.ts +134 -0
  38. package/dist/provider-types.js +3 -0
  39. package/dist/runtime-types.d.ts +84 -0
  40. package/dist/runtime-types.js +4 -0
  41. package/dist/tools.d.ts +16 -0
  42. package/dist/tools.js +141 -0
  43. package/dist/validator.d.ts +23 -0
  44. package/dist/validator.js +959 -0
  45. package/driver/codex/AGENTS.md +54 -0
  46. package/driver/hopskill-build/SKILL.md +137 -0
  47. package/driver/hopskill-build/references/spec-skeleton.md +132 -0
  48. package/driver/hopskill-build/references/step-type-cheatsheet.md +56 -0
  49. package/driver/hopskill-build/references/three-focus-rules.md +148 -0
  50. package/driver/hopspec-skill.md +187 -0
  51. package/driver/references/cli-discovery.md +36 -0
  52. package/driver/references/discovery.md +45 -0
  53. package/driver/references/driver-subagent.md +50 -0
  54. package/driver/references/parallel-worker.md +50 -0
  55. package/driver/references/step-execution-rules.md +47 -0
  56. package/package.json +52 -0
@@ -0,0 +1,92 @@
1
+ import type { ExecutionEngine } from './engine.js';
2
+ import type { ExecutableStepType, OutputDecl } from './ast-types.js';
3
+ import type { StepReady, ExecutionPaused } from './cli-types.js';
4
+ import type { HostConfig } from './provider-types.js';
5
+ /** StepDispatcher 构造配置(tool 迭代上限、全局 token 预算、单步超时等成本护栏参数)。见 [[step-dispatcher#^anc-exec-cost-guardrails]] */
6
+ export interface DispatcherConfig {
7
+ maxToolIterations?: number;
8
+ tokenBudget?: number;
9
+ timeoutSeconds?: number;
10
+ }
11
+ /** runSpec/resume 的返回结果:终态(completed/failed)或暂停信号(paused 携带 ExecutionPaused)。见 [[step-dispatcher#^anc-struct-step-dispatcher]] */
12
+ export interface RunResult {
13
+ status: 'completed' | 'failed' | 'paused';
14
+ outputs?: Record<string, unknown>;
15
+ failure?: {
16
+ step_id: string;
17
+ reason: string;
18
+ };
19
+ pause?: ExecutionPaused;
20
+ cumulative_tokens?: number;
21
+ }
22
+ /** 独立模式的驱动适配层:跑调度循环(init→next→execute→done)并直调 Anthropic API 完成单步推理与工具调用。见 [[step-dispatcher#^anc-struct-step-dispatcher]] */
23
+ export declare class StepDispatcher {
24
+ private engine;
25
+ private hostConfig;
26
+ private clients;
27
+ private defaultClient;
28
+ private toolProvider;
29
+ private cumulativeTokens;
30
+ private replanAttempts;
31
+ private maxToolIterations;
32
+ private tokenBudget;
33
+ private timeoutSeconds;
34
+ private pendingPause;
35
+ constructor(engine: ExecutionEngine, hostConfig: HostConfig, config?: DispatcherConfig);
36
+ runSpec(): Promise<RunResult>;
37
+ /**
38
+ * 同实例恢复:注入 caller 对 confirm 暂停步骤的决策,继续执行循环。 // @a: anc-exec-resume-semantics
39
+ * confirm 是唯一的暂停点(鉴权/决策环节):answer 作为步骤输出注入 → completeStep(audit hitl_decision)。
40
+ * commit 不暂停(授权在前序完成),故 resume 不处理 commit。
41
+ */
42
+ resume(stepId: string, answer: Record<string, unknown>): Promise<RunResult>;
43
+ resumeSpec(): Promise<RunResult>;
44
+ getCumulativeTokens(): number;
45
+ private executionLoop;
46
+ private handleStepReady;
47
+ private injectKnowledge;
48
+ private handleAdaptive;
49
+ private executeStepWithTimeout;
50
+ private executeStep;
51
+ private executeReasonOrCheck;
52
+ private executeActWithTools;
53
+ private executeConfirm;
54
+ private executeCommit;
55
+ private executeActBody;
56
+ private buildApiRequest;
57
+ private buildSystemPrompt;
58
+ private buildMessages;
59
+ formatInputs(inputs: Record<string, unknown>): string;
60
+ formatOutputSchema(schema: OutputDecl[]): string;
61
+ private selectTemperature;
62
+ private callLlmWithRetry;
63
+ private getMaxRetries;
64
+ private isRateLimited;
65
+ private isServerError;
66
+ private isTimeout;
67
+ private isNetworkError;
68
+ private isAuthFailure;
69
+ private isContextOverflow;
70
+ private checkBudget;
71
+ private checkNoneInputs;
72
+ private parseStepOutput;
73
+ private extractTextContent;
74
+ private findStepNode;
75
+ private resolveCredential;
76
+ resolveModel(stepType: ExecutableStepType, step?: StepReady): {
77
+ service_id: string;
78
+ model: string;
79
+ };
80
+ private parseModelRef;
81
+ private findStepInSpec;
82
+ /** 解析 API 输出 token 上限:env → resource_limits → 缺省。单点定义(原两处逐字复制)。
83
+ * 通用 env `HOPJIT_MAX_OUTPUT_TOKENS` 优先;`CLAUDE_CODE_MAX_OUTPUT_TOKENS` 保留作兼容(CC 宿主已设的不破坏)。 */
84
+ private resolveMaxOutputTokens;
85
+ /** replan 失败收尾:attempts+1 写回,达上限则 failStep。error 分支与 catch 分支共用。 */
86
+ private recordReplanFailure;
87
+ /** 步骤完成时把工具调用日志写入 HopLog(非空才写)。executeActWithTools / executeActBody 共用。 */
88
+ private flushToolLog;
89
+ private getClientForService;
90
+ private hasLackOfInfo;
91
+ private sleep;
92
+ }