@longtable/provider-claude 0.1.49 → 0.1.50

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/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ProviderCapabilities, QuestionRecord } from "@longtable/core";
1
+ import type { ProviderCapabilities, QuestionPromptType, QuestionRecord } from "@longtable/core";
2
2
  import type { CheckpointSignal, ResearcherProfile, ResolvedCheckpointPolicy, RuntimeGuidance } from "@longtable/checkpoints";
3
3
  import type { NumberedCheckpointSpec, SetupPersistedOutput } from "@longtable/setup";
4
4
  export interface ClaudeChoice {
@@ -19,6 +19,9 @@ export interface ClaudeStructuredCheckpoint {
19
19
  title: string;
20
20
  instructions?: string;
21
21
  choices: ClaudeChoice[];
22
+ inputMode?: QuestionPromptType;
23
+ multiSelect?: boolean;
24
+ fallbackPrompt?: string;
22
25
  guidance?: {
23
26
  closureDisposition: RuntimeGuidance["closureDisposition"];
24
27
  minimumQuestions: number;
@@ -35,14 +38,17 @@ export interface ClaudeCheckpointResult {
35
38
  policy: ResolvedCheckpointPolicy;
36
39
  guidance: RuntimeGuidance;
37
40
  structuredPrompt: ClaudeStructuredCheckpoint;
38
- askUserQuestionInput: ClaudeAskUserQuestionInput;
41
+ askUserQuestionInput?: ClaudeAskUserQuestionInput;
42
+ nativeStructured: boolean;
39
43
  blocking: boolean;
40
44
  }
41
45
  export interface ClaudeRenderedQuestionRecord {
42
46
  questionId: string;
43
47
  checkpointKey: string;
44
48
  structuredPrompt: ClaudeStructuredCheckpoint;
45
- askUserQuestionInput: ClaudeAskUserQuestionInput;
49
+ askUserQuestionInput?: ClaudeAskUserQuestionInput;
50
+ fallbackPrompt?: string;
51
+ nativeStructured: boolean;
46
52
  }
47
53
  export interface ClaudeRuntimeDefaults {
48
54
  askAtLeastTwoQuestionsInExplore: boolean;
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { resolveCheckpointPolicy } from "@longtable/checkpoints";
2
2
  import { resolveRuntimeGuidance } from "@longtable/checkpoints";
3
+ import { buildNumberedCheckpointPrompt } from "@longtable/setup";
3
4
  export const CLAUDE_PROVIDER_CAPABILITIES = {
4
5
  provider: "claude",
5
6
  nativeStructuredQuestions: true,
@@ -41,13 +42,23 @@ export function renderStructuredCheckpoint(spec, guidance) {
41
42
  if (guidance) {
42
43
  instructions.push(`Closure: ${guidance.closureDisposition}. Minimum questions before closure: ${guidance.minimumQuestions}.`);
43
44
  }
45
+ const inputMode = spec.selectionMode === "multi"
46
+ ? "multi_choice"
47
+ : spec.selectionMode === "free_text"
48
+ ? "free_text"
49
+ : "single_choice";
44
50
  return {
45
51
  title: spec.title,
46
52
  instructions: instructions.filter(Boolean).join(" "),
47
- choices: spec.options.map((option) => ({
48
- id: option.value,
49
- label: option.label
50
- })),
53
+ choices: inputMode === "free_text"
54
+ ? []
55
+ : spec.options.map((option) => ({
56
+ id: option.value,
57
+ label: option.label
58
+ })),
59
+ inputMode,
60
+ multiSelect: inputMode === "multi_choice",
61
+ ...(inputMode === "free_text" ? { fallbackPrompt: buildNumberedCheckpointPrompt(spec) } : {}),
51
62
  guidance: guidance
52
63
  ? {
53
64
  closureDisposition: guidance.closureDisposition,
@@ -59,6 +70,9 @@ export function renderStructuredCheckpoint(spec, guidance) {
59
70
  };
60
71
  }
61
72
  export function renderAskUserQuestionInput(checkpoint) {
73
+ if (checkpoint.inputMode === "free_text") {
74
+ throw new Error("Claude AskUserQuestion choice payload cannot render free-text LongTable checkpoints.");
75
+ }
62
76
  return {
63
77
  questions: [
64
78
  {
@@ -67,7 +81,7 @@ export function renderAskUserQuestionInput(checkpoint) {
67
81
  options: checkpoint.choices.map((choice) => ({
68
82
  label: choice.label
69
83
  })),
70
- multiSelect: false
84
+ multiSelect: checkpoint.multiSelect ?? false
71
85
  }
72
86
  ]
73
87
  };
@@ -89,36 +103,59 @@ export function renderStructuredQuestionRecord(record) {
89
103
  }]
90
104
  : [])
91
105
  ];
106
+ const instructions = [
107
+ record.prompt.question,
108
+ record.prompt.displayReason ? `Decision context: ${record.prompt.displayReason}` : undefined,
109
+ `Question id: ${record.id}`,
110
+ `Checkpoint: ${record.prompt.checkpointKey ?? "manual"}`,
111
+ `Required: ${record.prompt.required ? "yes" : "no"}`
112
+ ].filter(Boolean).join(" ");
113
+ const fallbackSpec = {
114
+ title: record.prompt.title,
115
+ instructions,
116
+ options: [],
117
+ allowRationale: false,
118
+ selectionMode: "free_text"
119
+ };
92
120
  return {
93
121
  title: record.prompt.title,
94
- instructions: [
95
- record.prompt.question,
96
- record.prompt.displayReason ? `Decision context: ${record.prompt.displayReason}` : undefined,
97
- `Question id: ${record.id}`,
98
- `Checkpoint: ${record.prompt.checkpointKey ?? "manual"}`,
99
- `Required: ${record.prompt.required ? "yes" : "no"}`
100
- ].filter(Boolean).join(" "),
101
- choices
122
+ instructions,
123
+ choices: record.prompt.type === "free_text" ? [] : choices,
124
+ inputMode: record.prompt.type,
125
+ multiSelect: record.prompt.type === "multi_choice",
126
+ ...(record.prompt.type === "free_text" ? { fallbackPrompt: buildNumberedCheckpointPrompt(fallbackSpec) } : {})
102
127
  };
103
128
  }
104
129
  export function renderQuestionRecordInput(record) {
105
130
  const structuredPrompt = renderStructuredQuestionRecord(record);
131
+ if (structuredPrompt.inputMode === "free_text") {
132
+ return {
133
+ questionId: record.id,
134
+ checkpointKey: record.prompt.checkpointKey ?? "manual",
135
+ structuredPrompt,
136
+ fallbackPrompt: structuredPrompt.fallbackPrompt,
137
+ nativeStructured: false
138
+ };
139
+ }
106
140
  return {
107
141
  questionId: record.id,
108
142
  checkpointKey: record.prompt.checkpointKey ?? "manual",
109
143
  structuredPrompt,
110
- askUserQuestionInput: renderAskUserQuestionInput(structuredPrompt)
144
+ askUserQuestionInput: renderAskUserQuestionInput(structuredPrompt),
145
+ nativeStructured: true
111
146
  };
112
147
  }
113
148
  export function createClaudeCheckpoint(context) {
114
149
  const policy = resolveCheckpointPolicy(context.profile, context.signal);
115
150
  const guidance = resolveRuntimeGuidance(context.profile, context.signal, policy);
116
151
  const structuredPrompt = renderStructuredCheckpoint(context.spec, guidance);
152
+ const nativeStructured = structuredPrompt.inputMode !== "free_text";
117
153
  return {
118
154
  policy,
119
155
  guidance,
120
156
  structuredPrompt,
121
- askUserQuestionInput: renderAskUserQuestionInput(structuredPrompt),
157
+ ...(nativeStructured ? { askUserQuestionInput: renderAskUserQuestionInput(structuredPrompt) } : {}),
158
+ nativeStructured,
122
159
  blocking: policy.blocking
123
160
  };
124
161
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longtable/provider-claude",
3
- "version": "0.1.49",
3
+ "version": "0.1.50",
4
4
  "private": false,
5
5
  "description": "Claude adapter surface for LongTable",
6
6
  "type": "module",
@@ -21,9 +21,9 @@
21
21
  "typecheck": "tsc -p tsconfig.json --noEmit"
22
22
  },
23
23
  "dependencies": {
24
- "@longtable/checkpoints": "0.1.49",
25
- "@longtable/core": "0.1.49",
26
- "@longtable/setup": "0.1.49"
24
+ "@longtable/checkpoints": "0.1.50",
25
+ "@longtable/core": "0.1.50",
26
+ "@longtable/setup": "0.1.50"
27
27
  },
28
28
  "devDependencies": {
29
29
  "typescript": "^5.6.0"