@crouton-kit/humanloop 0.3.6 → 0.3.7
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/api.js +3 -22
- package/dist/inbox/deck-factories.d.ts +12 -0
- package/dist/inbox/deck-factories.js +29 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/package.json +1 -1
package/dist/api.js
CHANGED
|
@@ -6,6 +6,7 @@ import { scanInbox } from './inbox/scan.js';
|
|
|
6
6
|
import { pickFromInbox } from './inbox/tui.js';
|
|
7
7
|
import { deckPath, atomicWriteJson, readJson } from './inbox/convention.js';
|
|
8
8
|
import { getTerminalSize } from './tui/terminal.js';
|
|
9
|
+
import { approveDeck, notifyDeck } from './inbox/deck-factories.js';
|
|
9
10
|
const RESPONSE_SCHEMA_ID = 'humanloop.response/v2';
|
|
10
11
|
function managedDir() {
|
|
11
12
|
return mkdtempSync(join(tmpdir(), 'hl-ix-'));
|
|
@@ -72,33 +73,13 @@ export async function ask(deck, opts = {}) {
|
|
|
72
73
|
}
|
|
73
74
|
/** Sugar: a single `kind:'validation'` Yes/No interaction. */
|
|
74
75
|
export async function approve(title, opts = {}) {
|
|
75
|
-
const deck = {
|
|
76
|
-
interactions: [{
|
|
77
|
-
id: 'approve',
|
|
78
|
-
title,
|
|
79
|
-
...(opts.subtitle !== undefined ? { subtitle: opts.subtitle } : {}),
|
|
80
|
-
...(opts.body !== undefined ? { body: opts.body } : {}),
|
|
81
|
-
kind: 'validation',
|
|
82
|
-
options: [
|
|
83
|
-
{ id: 'yes', label: 'Yes' },
|
|
84
|
-
{ id: 'no', label: 'No' },
|
|
85
|
-
],
|
|
86
|
-
}],
|
|
87
|
-
};
|
|
76
|
+
const deck = approveDeck(title, { subtitle: opts.subtitle, body: opts.body });
|
|
88
77
|
const env = await ask(deck, { dir: opts.dir, sessionId: opts.sessionId });
|
|
89
78
|
return env.responses[0]?.selectedOptionId === 'yes';
|
|
90
79
|
}
|
|
91
80
|
/** Sugar: a single `kind:'notify'` acknowledgement. */
|
|
92
81
|
export async function notify(title, body) {
|
|
93
|
-
const deck = {
|
|
94
|
-
interactions: [{
|
|
95
|
-
id: 'notify',
|
|
96
|
-
title,
|
|
97
|
-
...(body !== undefined ? { body } : {}),
|
|
98
|
-
kind: 'notify',
|
|
99
|
-
options: [{ id: 'ok', label: 'OK' }],
|
|
100
|
-
}],
|
|
101
|
-
};
|
|
82
|
+
const deck = notifyDeck(title, body !== undefined ? { body } : {});
|
|
102
83
|
await ask(deck, {});
|
|
103
84
|
}
|
|
104
85
|
/**
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Deck } from '../types.js';
|
|
2
|
+
export interface ApproveDeckOpts {
|
|
3
|
+
subtitle?: string;
|
|
4
|
+
body?: string;
|
|
5
|
+
}
|
|
6
|
+
/** Build a validated Yes/No validation deck. id: 'approve', kind: 'validation'. */
|
|
7
|
+
export declare function approveDeck(title: string, opts?: ApproveDeckOpts): Deck;
|
|
8
|
+
export interface NotifyDeckOpts {
|
|
9
|
+
body?: string;
|
|
10
|
+
}
|
|
11
|
+
/** Build a validated single-option notify deck. id: 'notify', kind: 'notify'. */
|
|
12
|
+
export declare function notifyDeck(title: string, opts?: NotifyDeckOpts): Deck;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { validateDeck } from './deck-schema.js';
|
|
2
|
+
/** Build a validated Yes/No validation deck. id: 'approve', kind: 'validation'. */
|
|
3
|
+
export function approveDeck(title, opts = {}) {
|
|
4
|
+
return validateDeck({
|
|
5
|
+
interactions: [{
|
|
6
|
+
id: 'approve',
|
|
7
|
+
title,
|
|
8
|
+
...(opts.subtitle !== undefined ? { subtitle: opts.subtitle } : {}),
|
|
9
|
+
...(opts.body !== undefined ? { body: opts.body } : {}),
|
|
10
|
+
kind: 'validation',
|
|
11
|
+
options: [
|
|
12
|
+
{ id: 'yes', label: 'Yes' },
|
|
13
|
+
{ id: 'no', label: 'No' },
|
|
14
|
+
],
|
|
15
|
+
}],
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/** Build a validated single-option notify deck. id: 'notify', kind: 'notify'. */
|
|
19
|
+
export function notifyDeck(title, opts = {}) {
|
|
20
|
+
return validateDeck({
|
|
21
|
+
interactions: [{
|
|
22
|
+
id: 'notify',
|
|
23
|
+
title,
|
|
24
|
+
...(opts.body !== undefined ? { body: opts.body } : {}),
|
|
25
|
+
kind: 'notify',
|
|
26
|
+
options: [{ id: 'ok', label: 'OK' }],
|
|
27
|
+
}],
|
|
28
|
+
});
|
|
29
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export { display } from './surfaces/display.js';
|
|
|
8
8
|
export { scanInbox } from './inbox/scan.js';
|
|
9
9
|
export { renderMarkdown, checkMarkdown, ensureRenderer, isRendererReady, } from './render/termrender.js';
|
|
10
10
|
export { parseDeck, validateDeck, deckSchema } from './inbox/deck-schema.js';
|
|
11
|
+
export { approveDeck, notifyDeck } from './inbox/deck-factories.js';
|
|
12
|
+
export type { ApproveDeckOpts, NotifyDeckOpts } from './inbox/deck-factories.js';
|
|
11
13
|
export { deckPath, responsePath, progressPath, visualsDir, interactionState, isResolved, isClaimed, atomicWriteJson, readJson, writeResponse, writeProgress, clearProgress, } from './inbox/convention.js';
|
|
12
14
|
export type { InteractionState } from './inbox/convention.js';
|
|
13
15
|
export type { Interaction, InteractionOption, InteractionResponse, InteractionKind, Deck, DeckSource, MountedPanel, MountedPanelOpts, GenerateVisual, VisualBlock, FeedbackComment, FeedbackResult, ResolutionEnvelope, InboxItem, DisplayOpts, } from './types.js';
|
package/dist/index.js
CHANGED
|
@@ -11,5 +11,8 @@ export { scanInbox } from './inbox/scan.js';
|
|
|
11
11
|
export { renderMarkdown, checkMarkdown, ensureRenderer, isRendererReady, } from './render/termrender.js';
|
|
12
12
|
// Canonical deck schema + parsing/validation (consumers stop forking it).
|
|
13
13
|
export { parseDeck, validateDeck, deckSchema } from './inbox/deck-schema.js';
|
|
14
|
+
// Deck factories — pure builders for common deck shapes (sugar for SDK consumers
|
|
15
|
+
// who want validated Yes/No or notify decks without inline construction).
|
|
16
|
+
export { approveDeck, notifyDeck } from './inbox/deck-factories.js';
|
|
14
17
|
// Interaction-directory convention helpers (§B) — names humanloop owns.
|
|
15
18
|
export { deckPath, responsePath, progressPath, visualsDir, interactionState, isResolved, isClaimed, atomicWriteJson, readJson, writeResponse, writeProgress, clearProgress, } from './inbox/convention.js';
|