@cultured_computer/sight 0.10.1 → 0.10.3
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/CHANGELOG.md +40 -3
- package/README.md +95 -252
- package/dist/cli.js +5527 -151
- package/dist/index.cjs +105 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +100 -6
- package/dist/index.d.ts +100 -6
- package/dist/index.js +105 -24
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -2355,8 +2355,8 @@ declare function sightTelemetry(options?: SightAiTelemetryOptions): SightAiTelem
|
|
|
2355
2355
|
|
|
2356
2356
|
/**
|
|
2357
2357
|
* The serving client: a typed client for the Field API, the routes that put
|
|
2358
|
-
* a profile (a SOUL.md) at a name, serve it turn by turn
|
|
2359
|
-
* record. It is separate from the capture API (`Sight`) and shares nothing
|
|
2358
|
+
* a profile (a SOUL.md or complete scene) at a name, serve it turn by turn
|
|
2359
|
+
* and read its record. It is separate from the capture API (`Sight`) and shares nothing
|
|
2360
2360
|
* with it: its own key, its own requests, no process state.
|
|
2361
2361
|
*
|
|
2362
2362
|
* import { createFieldClient } from '@cultured_computer/sight';
|
|
@@ -2368,7 +2368,8 @@ declare function sightTelemetry(options?: SightAiTelemetryOptions): SightAiTelem
|
|
|
2368
2368
|
*
|
|
2369
2369
|
* Every refused request throws a `FieldRefusal` carrying the HTTP status,
|
|
2370
2370
|
* the refusal `code` and, when the answer has one, the `reason`. Nothing is
|
|
2371
|
-
* retried
|
|
2371
|
+
* retried automatically. Identified turns use `/turn-requests`; `replay`
|
|
2372
|
+
* reads the original receipt without admitting another provider call.
|
|
2372
2373
|
*
|
|
2373
2374
|
* Server-side only: the key it holds can rewrite the profile.
|
|
2374
2375
|
*/
|
|
@@ -2380,7 +2381,7 @@ declare const DEFAULT_FIELD_ENDPOINT = "https://api.cultured.computer";
|
|
|
2380
2381
|
* profile read. A refusal with no code (a 401, a 403 for a key that lacks a
|
|
2381
2382
|
* permission, a 413) carries `code: null`.
|
|
2382
2383
|
*/
|
|
2383
|
-
declare const FIELD_REFUSAL_CODES: readonly ["invalid_body", "forbidden", "not_enabled", "no_such_profile", "no_such_endpoint", "no_such_conversation", "conversation_unknown", "archived", "revoked", "link_inactive", "conversation_conflict", "opening_forbidden", "opening_conflict", "runtime_forbidden", "invalid_reasoning_effort", "invalid_max_output_tokens", "invalid_reply_check", "conversation_ended", "no_live_version", "no_owner", "model_unavailable", "daily_cap", "link_session_cap", "rate_limited", "turn_cap", "stale_turn_index", "record_gap", "busy", "interrupted", "not_connected", "budget", "provider_error", "provider_timeout", "turn_failed", "request_unknown", "request_conflict", "request_pending", "request_interrupted", "replay_expired", "put_in_progress", "scene_live", "precondition_failed", "invalid_consent", "invalid_safeguards", "invalid_scrub", "invalid_fallback", "invalid_scene", "not_a_soul_md", "not_a_scene"];
|
|
2384
|
+
declare const FIELD_REFUSAL_CODES: readonly ["invalid_body", "forbidden", "not_enabled", "no_such_profile", "no_such_endpoint", "no_such_conversation", "conversation_unknown", "archived", "revoked", "link_inactive", "conversation_conflict", "constructed_forbidden", "opening_forbidden", "opening_conflict", "runtime_forbidden", "invalid_reasoning_effort", "invalid_max_output_tokens", "invalid_reply_check", "conversation_ended", "no_live_version", "no_owner", "model_unavailable", "daily_cap", "link_session_cap", "rate_limited", "turn_cap", "stale_turn_index", "record_gap", "busy", "interrupted", "not_connected", "budget", "provider_error", "provider_timeout", "turn_failed", "request_unknown", "request_conflict", "request_pending", "request_interrupted", "replay_expired", "put_in_progress", "scene_live", "precondition_failed", "invalid_consent", "invalid_safeguards", "invalid_scrub", "invalid_fallback", "invalid_scene", "not_a_soul_md", "not_a_scene"];
|
|
2384
2385
|
type FieldRefusalCode = (typeof FIELD_REFUSAL_CODES)[number];
|
|
2385
2386
|
/**
|
|
2386
2387
|
* The reasoning efforts a profile or a conversation can ask for. `none`
|
|
@@ -2430,6 +2431,8 @@ type FieldRuntime = {
|
|
|
2430
2431
|
* effort it lists; nothing when it lists none.
|
|
2431
2432
|
*/
|
|
2432
2433
|
reasoningEffort?: FieldReasoningEffort;
|
|
2434
|
+
/** The declared reply screens: off, mark only, or re-voice a confirmed flat refusal. */
|
|
2435
|
+
replyCheck?: 'off' | 'mark' | 'revoice';
|
|
2433
2436
|
};
|
|
2434
2437
|
/** A fixed platform text you must show the person, before the reply. */
|
|
2435
2438
|
type FieldNotice = {
|
|
@@ -2522,6 +2525,27 @@ type FieldProfileEndpoint = {
|
|
|
2522
2525
|
idleMinutes: number;
|
|
2523
2526
|
turnsPerConversation: number;
|
|
2524
2527
|
conversationsPerDay: number;
|
|
2528
|
+
/** Effective execution configuration, readable by the profile key. */
|
|
2529
|
+
deploymentId?: string;
|
|
2530
|
+
readsPosture?: 'full' | 'post-reply';
|
|
2531
|
+
closingLine?: string | null;
|
|
2532
|
+
revealsState?: boolean;
|
|
2533
|
+
};
|
|
2534
|
+
type FieldSceneDocument = {
|
|
2535
|
+
title?: string;
|
|
2536
|
+
sections: unknown[];
|
|
2537
|
+
settings?: {
|
|
2538
|
+
model?: string;
|
|
2539
|
+
temperature?: number;
|
|
2540
|
+
consent?: boolean | string;
|
|
2541
|
+
safeguards?: string;
|
|
2542
|
+
fallback?: string;
|
|
2543
|
+
scrub?: string;
|
|
2544
|
+
replyCheck?: string;
|
|
2545
|
+
reasoningEffort?: string;
|
|
2546
|
+
maxOutputTokens?: number | string;
|
|
2547
|
+
reader?: 'jev-latest' | null;
|
|
2548
|
+
};
|
|
2525
2549
|
};
|
|
2526
2550
|
/** The answer to `profiles.put`. */
|
|
2527
2551
|
type FieldProfilePut = {
|
|
@@ -2576,11 +2600,13 @@ type FieldProfilePut = {
|
|
|
2576
2600
|
/** The answer to `profiles.get`. */
|
|
2577
2601
|
type FieldProfile = {
|
|
2578
2602
|
profile: string;
|
|
2603
|
+
deploymentId?: string;
|
|
2579
2604
|
floor: 'steer' | 'exit';
|
|
2580
2605
|
archived: boolean;
|
|
2581
2606
|
archivedAt: string | null;
|
|
2582
2607
|
version: {
|
|
2583
2608
|
id: string;
|
|
2609
|
+
contentHash: string;
|
|
2584
2610
|
configHash: string;
|
|
2585
2611
|
label: string;
|
|
2586
2612
|
} | null;
|
|
@@ -2631,6 +2657,8 @@ type FieldSessionSummary = {
|
|
|
2631
2657
|
error?: string;
|
|
2632
2658
|
turns: number;
|
|
2633
2659
|
rehearsal: boolean;
|
|
2660
|
+
/** The start's independent exemplar-sampling seed; null keeps legacy run-id sampling. */
|
|
2661
|
+
moveSeed: number | null;
|
|
2634
2662
|
origin: 'observed' | 'constructed';
|
|
2635
2663
|
opening: {
|
|
2636
2664
|
turns: number;
|
|
@@ -2654,6 +2682,21 @@ type FieldSessionsPage = {
|
|
|
2654
2682
|
versions: string;
|
|
2655
2683
|
};
|
|
2656
2684
|
};
|
|
2685
|
+
type FieldSampledMove = {
|
|
2686
|
+
blockId: string;
|
|
2687
|
+
moveId: string;
|
|
2688
|
+
candidates: Array<{
|
|
2689
|
+
label: string;
|
|
2690
|
+
}>;
|
|
2691
|
+
/** Actual selection propensities in candidate order. */
|
|
2692
|
+
propensities: number[];
|
|
2693
|
+
selectedIndex: number;
|
|
2694
|
+
selectionMeta: {
|
|
2695
|
+
temperature: number;
|
|
2696
|
+
seed: string;
|
|
2697
|
+
policy_version: 'uniform-v1';
|
|
2698
|
+
};
|
|
2699
|
+
};
|
|
2657
2700
|
/** One turn of a session's record. */
|
|
2658
2701
|
type FieldSessionTurn = {
|
|
2659
2702
|
index: number;
|
|
@@ -2703,6 +2746,8 @@ type FieldSessionTurn = {
|
|
|
2703
2746
|
version: string | null;
|
|
2704
2747
|
}>;
|
|
2705
2748
|
moves: unknown[];
|
|
2749
|
+
/** One draw per active moves block; empty when no exemplar was sampled. */
|
|
2750
|
+
sampledMoves: FieldSampledMove[];
|
|
2706
2751
|
floor?: unknown;
|
|
2707
2752
|
notices?: FieldNotice[];
|
|
2708
2753
|
storedHistoryTurns?: number;
|
|
@@ -2750,6 +2795,16 @@ type FieldConversation = {
|
|
|
2750
2795
|
/** The path of the session's record (`GET` it with the same key). */
|
|
2751
2796
|
record: string;
|
|
2752
2797
|
};
|
|
2798
|
+
/** The answer to `conversations.end`. */
|
|
2799
|
+
type FieldConversationEnd = {
|
|
2800
|
+
ok: true;
|
|
2801
|
+
/** True when an earlier end already closed the conversation. */
|
|
2802
|
+
alreadyEnded: boolean;
|
|
2803
|
+
runId: string;
|
|
2804
|
+
sessionId: string;
|
|
2805
|
+
/** The path of the session's record (`GET` it with the same key). */
|
|
2806
|
+
record: string;
|
|
2807
|
+
};
|
|
2753
2808
|
/** The answer to `turns.send`. */
|
|
2754
2809
|
type FieldTurnAnswer = {
|
|
2755
2810
|
reply: string;
|
|
@@ -2838,7 +2893,7 @@ type FieldClientOptions = {
|
|
|
2838
2893
|
/** The API host. Default `https://api.cultured.computer`. */
|
|
2839
2894
|
endpoint?: string;
|
|
2840
2895
|
};
|
|
2841
|
-
/** Options of `profiles.put`. Each overrides the
|
|
2896
|
+
/** Options of `profiles.put` and `profiles.putScene`. Each overrides the document's settings for this put. */
|
|
2842
2897
|
type FieldPutOptions = FieldRuntime & {
|
|
2843
2898
|
/** A model id that answers when the model fails before its reply started, or `none`. */
|
|
2844
2899
|
fallback?: string;
|
|
@@ -2855,6 +2910,8 @@ type FieldPutOptions = FieldRuntime & {
|
|
|
2855
2910
|
force?: boolean;
|
|
2856
2911
|
/** A conditional put: the `etag` a read or the last put answered. */
|
|
2857
2912
|
ifMatch?: string;
|
|
2913
|
+
/** Create-only with `*`: fail if the profile already exists. */
|
|
2914
|
+
ifNoneMatch?: string;
|
|
2858
2915
|
signal?: AbortSignal;
|
|
2859
2916
|
};
|
|
2860
2917
|
type FieldStartOptions = {
|
|
@@ -2877,8 +2934,17 @@ type FieldStartOptions = {
|
|
|
2877
2934
|
role: 'person' | 'assistant';
|
|
2878
2935
|
text: string;
|
|
2879
2936
|
}>;
|
|
2937
|
+
/** Explicit provenance for a scripted run, including one with no constructed opening. */
|
|
2938
|
+
constructed?: 'scripted';
|
|
2880
2939
|
/** A signed 32-bit integer; each turn sends the seed plus its index where the route takes one. */
|
|
2881
2940
|
seed?: number;
|
|
2941
|
+
/** Independent exemplar-move sampling seed; absent keeps the service's legacy behavior. */
|
|
2942
|
+
moveSeed?: number;
|
|
2943
|
+
signal?: AbortSignal;
|
|
2944
|
+
};
|
|
2945
|
+
type FieldEndOptions = {
|
|
2946
|
+
/** Your own id for the conversation, at most 200 characters. */
|
|
2947
|
+
conversation: string;
|
|
2882
2948
|
signal?: AbortSignal;
|
|
2883
2949
|
};
|
|
2884
2950
|
type FieldTurnOptions = {
|
|
@@ -2890,6 +2956,18 @@ type FieldTurnOptions = {
|
|
|
2890
2956
|
};
|
|
2891
2957
|
signal?: AbortSignal;
|
|
2892
2958
|
};
|
|
2959
|
+
type FieldTurnRequestOptions = FieldTurnOptions & {
|
|
2960
|
+
/** A UUID stable for this logical turn. Reuse it only with the same conversation, message and index. */
|
|
2961
|
+
requestId: string;
|
|
2962
|
+
/** Required request identity: the next turn index, zero on a new conversation. */
|
|
2963
|
+
resume: {
|
|
2964
|
+
turnIndex: number;
|
|
2965
|
+
};
|
|
2966
|
+
};
|
|
2967
|
+
type FieldEndpointPatchOptions = {
|
|
2968
|
+
revealsState: boolean;
|
|
2969
|
+
signal?: AbortSignal;
|
|
2970
|
+
};
|
|
2893
2971
|
type FieldSessionsOptions = {
|
|
2894
2972
|
/** Your own conversation id, exact match. */
|
|
2895
2973
|
conversation?: string;
|
|
@@ -2906,6 +2984,8 @@ type FieldClient = {
|
|
|
2906
2984
|
profiles: {
|
|
2907
2985
|
/** Put a SOUL.md at a name: creates the profile, or saves a new version or new settings. */
|
|
2908
2986
|
put(name: string, soulMarkdown: string, options?: FieldPutOptions): Promise<FieldProfilePut>;
|
|
2987
|
+
/** Put one complete scene document; a string body is sent byte for byte. */
|
|
2988
|
+
putScene(name: string, scene: FieldSceneDocument | string, options?: FieldPutOptions): Promise<FieldProfilePut>;
|
|
2909
2989
|
/** Read a profile: its live version, runtime, limits, safeguards and connection. */
|
|
2910
2990
|
get(name: string, options?: {
|
|
2911
2991
|
signal?: AbortSignal;
|
|
@@ -2913,9 +2993,15 @@ type FieldClient = {
|
|
|
2913
2993
|
/** List a profile's served sessions, newest first, one page at a time. */
|
|
2914
2994
|
sessions(name: string, options?: FieldSessionsOptions): Promise<FieldSessionsPage>;
|
|
2915
2995
|
};
|
|
2996
|
+
endpoints: {
|
|
2997
|
+
/** Change keyed endpoint configuration by the id returned on the profile read. */
|
|
2998
|
+
update(id: string, options: FieldEndpointPatchOptions): Promise<FieldProfileEndpoint>;
|
|
2999
|
+
};
|
|
2916
3000
|
conversations: {
|
|
2917
3001
|
/** Start a conversation, or answer the running one under the same id. */
|
|
2918
3002
|
start(profile: string, options: FieldStartOptions): Promise<FieldConversation>;
|
|
3003
|
+
/** End a conversation without a model call; replaying the end is safe. */
|
|
3004
|
+
end(profile: string, options: FieldEndOptions): Promise<FieldConversationEnd>;
|
|
2919
3005
|
};
|
|
2920
3006
|
turns: {
|
|
2921
3007
|
/** Serve one turn and answer it as one JSON body. Throws `FieldRefusal` when the turn fails. */
|
|
@@ -2926,6 +3012,14 @@ type FieldClient = {
|
|
|
2926
3012
|
* started arrives as an `error` frame and ends the stream.
|
|
2927
3013
|
*/
|
|
2928
3014
|
stream(profile: string, options: FieldTurnOptions): AsyncGenerator<FieldTurnFrame, void, undefined>;
|
|
3015
|
+
/** Admit one identified turn, or replay an existing receipt with the same identity. */
|
|
3016
|
+
request(profile: string, options: FieldTurnRequestOptions): Promise<FieldTurnAnswer>;
|
|
3017
|
+
/** Read only the identified turn's receipt; never admits a conversation or model call. */
|
|
3018
|
+
replay(profile: string, options: FieldTurnRequestOptions): Promise<FieldTurnAnswer>;
|
|
3019
|
+
/** The identified request as raw ordered SSE frames. */
|
|
3020
|
+
requestStream(profile: string, options: FieldTurnRequestOptions): AsyncGenerator<FieldTurnFrame, void, undefined>;
|
|
3021
|
+
/** Replay-only receipt recovery as raw ordered SSE frames. */
|
|
3022
|
+
replayStream(profile: string, options: FieldTurnRequestOptions): AsyncGenerator<FieldTurnFrame, void, undefined>;
|
|
2929
3023
|
};
|
|
2930
3024
|
sessions: {
|
|
2931
3025
|
/** Read one session's record, turn by turn. */
|
|
@@ -2940,4 +3034,4 @@ type FieldClient = {
|
|
|
2940
3034
|
*/
|
|
2941
3035
|
declare function createFieldClient(options: FieldClientOptions): FieldClient;
|
|
2942
3036
|
|
|
2943
|
-
export { type AlignmentProvenance, type CaptureTurnInput, type CapturedTurn, DEFAULT_FIELD_ENDPOINT, type EnvironmentEventInput, FIELD_REASONING_EFFORTS, FIELD_REFUSAL_CODES, type FieldClient, type FieldClientOptions, type FieldConnection, type FieldConversation, type FieldDoneFrame, type FieldEmptyCompletionReason, type FieldEndedReason, type FieldErrorFrame, type FieldEventRecord, type FieldLimits, type FieldNotice, type FieldProfile, type FieldProfileEndpoint, type FieldProfileLinks, type FieldProfilePut, type FieldProfileRuntimeSource, type FieldPutOptions, type FieldReadFrame, type FieldReasoningEffort, FieldRefusal, type FieldRefusalCode, type FieldRunFrame, type FieldRuntime, type FieldRuntimeSource, type FieldSafeguards, type FieldSessionRecord, type FieldSessionSummary, type FieldSessionTurn, type FieldSessionsOptions, type FieldSessionsPage, type FieldStartOptions, type FieldTurnAnswer, type FieldTurnFrame, type FieldTurnOptions, type FieldVersionRef, type OutcomeEventEmit, type OutcomeHook, type OutcomeResult, type PersonaConfig, Probe, type ProbeConfig, type ProbeConfigInput, SPAN_INTERVAL_KINDS, SPAN_PAYLOAD_STATES, SPAN_STATUSES, SPAN_TYPES, SPAN_V2_STATUSES, Probe as Sight, type SightAiTelemetry, type SightAiTelemetryOptions, type AlignmentProvenance as SightAlignmentProvenance, type CaptureTurnInput as SightCaptureTurnInput, type CapturedTurn as SightCapturedTurn, type ProbeConfig as SightConfig, type ProbeConfigInput as SightConfigInput, type EnvironmentEventInput as SightEnvironmentEventInput, type OutcomeEventEmit as SightOutcomeEventEmit, type OutcomeHook as SightOutcomeHook, type OutcomeResult as SightOutcomeResult, type PersonaConfig as SightPersonaConfig, type SpanInput as SightSpanInput, type SpanInputV2 as SightSpanInputV2, type SpansBatch as SightSpansBatch, type SpanInput, SpanInputSchema, type SpanInputV1, SpanInputV1Schema, type SpanInputV2, SpanInputV2Schema, type SpanInterval, type SpanIntervalKind, SpanIntervalSchema, type SpanPayload, SpanPayloadSchema, type SpanPayloadState, type SpanStatus, type SpanType, type SpansBatch, SpansBatchSchema, createFieldClient, sightTelemetry, wrapOpenAI };
|
|
3037
|
+
export { type AlignmentProvenance, type CaptureTurnInput, type CapturedTurn, DEFAULT_FIELD_ENDPOINT, type EnvironmentEventInput, FIELD_REASONING_EFFORTS, FIELD_REFUSAL_CODES, type FieldClient, type FieldClientOptions, type FieldConnection, type FieldConversation, type FieldDoneFrame, type FieldEmptyCompletionReason, type FieldEndedReason, type FieldEndpointPatchOptions, type FieldErrorFrame, type FieldEventRecord, type FieldLimits, type FieldNotice, type FieldProfile, type FieldProfileEndpoint, type FieldProfileLinks, type FieldProfilePut, type FieldProfileRuntimeSource, type FieldPutOptions, type FieldReadFrame, type FieldReasoningEffort, FieldRefusal, type FieldRefusalCode, type FieldRunFrame, type FieldRuntime, type FieldRuntimeSource, type FieldSafeguards, type FieldSceneDocument, type FieldSessionRecord, type FieldSessionSummary, type FieldSessionTurn, type FieldSessionsOptions, type FieldSessionsPage, type FieldStartOptions, type FieldTurnAnswer, type FieldTurnFrame, type FieldTurnOptions, type FieldTurnRequestOptions, type FieldVersionRef, type OutcomeEventEmit, type OutcomeHook, type OutcomeResult, type PersonaConfig, Probe, type ProbeConfig, type ProbeConfigInput, SPAN_INTERVAL_KINDS, SPAN_PAYLOAD_STATES, SPAN_STATUSES, SPAN_TYPES, SPAN_V2_STATUSES, Probe as Sight, type SightAiTelemetry, type SightAiTelemetryOptions, type AlignmentProvenance as SightAlignmentProvenance, type CaptureTurnInput as SightCaptureTurnInput, type CapturedTurn as SightCapturedTurn, type ProbeConfig as SightConfig, type ProbeConfigInput as SightConfigInput, type EnvironmentEventInput as SightEnvironmentEventInput, type OutcomeEventEmit as SightOutcomeEventEmit, type OutcomeHook as SightOutcomeHook, type OutcomeResult as SightOutcomeResult, type PersonaConfig as SightPersonaConfig, type SpanInput as SightSpanInput, type SpanInputV2 as SightSpanInputV2, type SpansBatch as SightSpansBatch, type SpanInput, SpanInputSchema, type SpanInputV1, SpanInputV1Schema, type SpanInputV2, SpanInputV2Schema, type SpanInterval, type SpanIntervalKind, SpanIntervalSchema, type SpanPayload, SpanPayloadSchema, type SpanPayloadState, type SpanStatus, type SpanType, type SpansBatch, SpansBatchSchema, createFieldClient, sightTelemetry, wrapOpenAI };
|
package/dist/index.d.ts
CHANGED
|
@@ -2355,8 +2355,8 @@ declare function sightTelemetry(options?: SightAiTelemetryOptions): SightAiTelem
|
|
|
2355
2355
|
|
|
2356
2356
|
/**
|
|
2357
2357
|
* The serving client: a typed client for the Field API, the routes that put
|
|
2358
|
-
* a profile (a SOUL.md) at a name, serve it turn by turn
|
|
2359
|
-
* record. It is separate from the capture API (`Sight`) and shares nothing
|
|
2358
|
+
* a profile (a SOUL.md or complete scene) at a name, serve it turn by turn
|
|
2359
|
+
* and read its record. It is separate from the capture API (`Sight`) and shares nothing
|
|
2360
2360
|
* with it: its own key, its own requests, no process state.
|
|
2361
2361
|
*
|
|
2362
2362
|
* import { createFieldClient } from '@cultured_computer/sight';
|
|
@@ -2368,7 +2368,8 @@ declare function sightTelemetry(options?: SightAiTelemetryOptions): SightAiTelem
|
|
|
2368
2368
|
*
|
|
2369
2369
|
* Every refused request throws a `FieldRefusal` carrying the HTTP status,
|
|
2370
2370
|
* the refusal `code` and, when the answer has one, the `reason`. Nothing is
|
|
2371
|
-
* retried
|
|
2371
|
+
* retried automatically. Identified turns use `/turn-requests`; `replay`
|
|
2372
|
+
* reads the original receipt without admitting another provider call.
|
|
2372
2373
|
*
|
|
2373
2374
|
* Server-side only: the key it holds can rewrite the profile.
|
|
2374
2375
|
*/
|
|
@@ -2380,7 +2381,7 @@ declare const DEFAULT_FIELD_ENDPOINT = "https://api.cultured.computer";
|
|
|
2380
2381
|
* profile read. A refusal with no code (a 401, a 403 for a key that lacks a
|
|
2381
2382
|
* permission, a 413) carries `code: null`.
|
|
2382
2383
|
*/
|
|
2383
|
-
declare const FIELD_REFUSAL_CODES: readonly ["invalid_body", "forbidden", "not_enabled", "no_such_profile", "no_such_endpoint", "no_such_conversation", "conversation_unknown", "archived", "revoked", "link_inactive", "conversation_conflict", "opening_forbidden", "opening_conflict", "runtime_forbidden", "invalid_reasoning_effort", "invalid_max_output_tokens", "invalid_reply_check", "conversation_ended", "no_live_version", "no_owner", "model_unavailable", "daily_cap", "link_session_cap", "rate_limited", "turn_cap", "stale_turn_index", "record_gap", "busy", "interrupted", "not_connected", "budget", "provider_error", "provider_timeout", "turn_failed", "request_unknown", "request_conflict", "request_pending", "request_interrupted", "replay_expired", "put_in_progress", "scene_live", "precondition_failed", "invalid_consent", "invalid_safeguards", "invalid_scrub", "invalid_fallback", "invalid_scene", "not_a_soul_md", "not_a_scene"];
|
|
2384
|
+
declare const FIELD_REFUSAL_CODES: readonly ["invalid_body", "forbidden", "not_enabled", "no_such_profile", "no_such_endpoint", "no_such_conversation", "conversation_unknown", "archived", "revoked", "link_inactive", "conversation_conflict", "constructed_forbidden", "opening_forbidden", "opening_conflict", "runtime_forbidden", "invalid_reasoning_effort", "invalid_max_output_tokens", "invalid_reply_check", "conversation_ended", "no_live_version", "no_owner", "model_unavailable", "daily_cap", "link_session_cap", "rate_limited", "turn_cap", "stale_turn_index", "record_gap", "busy", "interrupted", "not_connected", "budget", "provider_error", "provider_timeout", "turn_failed", "request_unknown", "request_conflict", "request_pending", "request_interrupted", "replay_expired", "put_in_progress", "scene_live", "precondition_failed", "invalid_consent", "invalid_safeguards", "invalid_scrub", "invalid_fallback", "invalid_scene", "not_a_soul_md", "not_a_scene"];
|
|
2384
2385
|
type FieldRefusalCode = (typeof FIELD_REFUSAL_CODES)[number];
|
|
2385
2386
|
/**
|
|
2386
2387
|
* The reasoning efforts a profile or a conversation can ask for. `none`
|
|
@@ -2430,6 +2431,8 @@ type FieldRuntime = {
|
|
|
2430
2431
|
* effort it lists; nothing when it lists none.
|
|
2431
2432
|
*/
|
|
2432
2433
|
reasoningEffort?: FieldReasoningEffort;
|
|
2434
|
+
/** The declared reply screens: off, mark only, or re-voice a confirmed flat refusal. */
|
|
2435
|
+
replyCheck?: 'off' | 'mark' | 'revoice';
|
|
2433
2436
|
};
|
|
2434
2437
|
/** A fixed platform text you must show the person, before the reply. */
|
|
2435
2438
|
type FieldNotice = {
|
|
@@ -2522,6 +2525,27 @@ type FieldProfileEndpoint = {
|
|
|
2522
2525
|
idleMinutes: number;
|
|
2523
2526
|
turnsPerConversation: number;
|
|
2524
2527
|
conversationsPerDay: number;
|
|
2528
|
+
/** Effective execution configuration, readable by the profile key. */
|
|
2529
|
+
deploymentId?: string;
|
|
2530
|
+
readsPosture?: 'full' | 'post-reply';
|
|
2531
|
+
closingLine?: string | null;
|
|
2532
|
+
revealsState?: boolean;
|
|
2533
|
+
};
|
|
2534
|
+
type FieldSceneDocument = {
|
|
2535
|
+
title?: string;
|
|
2536
|
+
sections: unknown[];
|
|
2537
|
+
settings?: {
|
|
2538
|
+
model?: string;
|
|
2539
|
+
temperature?: number;
|
|
2540
|
+
consent?: boolean | string;
|
|
2541
|
+
safeguards?: string;
|
|
2542
|
+
fallback?: string;
|
|
2543
|
+
scrub?: string;
|
|
2544
|
+
replyCheck?: string;
|
|
2545
|
+
reasoningEffort?: string;
|
|
2546
|
+
maxOutputTokens?: number | string;
|
|
2547
|
+
reader?: 'jev-latest' | null;
|
|
2548
|
+
};
|
|
2525
2549
|
};
|
|
2526
2550
|
/** The answer to `profiles.put`. */
|
|
2527
2551
|
type FieldProfilePut = {
|
|
@@ -2576,11 +2600,13 @@ type FieldProfilePut = {
|
|
|
2576
2600
|
/** The answer to `profiles.get`. */
|
|
2577
2601
|
type FieldProfile = {
|
|
2578
2602
|
profile: string;
|
|
2603
|
+
deploymentId?: string;
|
|
2579
2604
|
floor: 'steer' | 'exit';
|
|
2580
2605
|
archived: boolean;
|
|
2581
2606
|
archivedAt: string | null;
|
|
2582
2607
|
version: {
|
|
2583
2608
|
id: string;
|
|
2609
|
+
contentHash: string;
|
|
2584
2610
|
configHash: string;
|
|
2585
2611
|
label: string;
|
|
2586
2612
|
} | null;
|
|
@@ -2631,6 +2657,8 @@ type FieldSessionSummary = {
|
|
|
2631
2657
|
error?: string;
|
|
2632
2658
|
turns: number;
|
|
2633
2659
|
rehearsal: boolean;
|
|
2660
|
+
/** The start's independent exemplar-sampling seed; null keeps legacy run-id sampling. */
|
|
2661
|
+
moveSeed: number | null;
|
|
2634
2662
|
origin: 'observed' | 'constructed';
|
|
2635
2663
|
opening: {
|
|
2636
2664
|
turns: number;
|
|
@@ -2654,6 +2682,21 @@ type FieldSessionsPage = {
|
|
|
2654
2682
|
versions: string;
|
|
2655
2683
|
};
|
|
2656
2684
|
};
|
|
2685
|
+
type FieldSampledMove = {
|
|
2686
|
+
blockId: string;
|
|
2687
|
+
moveId: string;
|
|
2688
|
+
candidates: Array<{
|
|
2689
|
+
label: string;
|
|
2690
|
+
}>;
|
|
2691
|
+
/** Actual selection propensities in candidate order. */
|
|
2692
|
+
propensities: number[];
|
|
2693
|
+
selectedIndex: number;
|
|
2694
|
+
selectionMeta: {
|
|
2695
|
+
temperature: number;
|
|
2696
|
+
seed: string;
|
|
2697
|
+
policy_version: 'uniform-v1';
|
|
2698
|
+
};
|
|
2699
|
+
};
|
|
2657
2700
|
/** One turn of a session's record. */
|
|
2658
2701
|
type FieldSessionTurn = {
|
|
2659
2702
|
index: number;
|
|
@@ -2703,6 +2746,8 @@ type FieldSessionTurn = {
|
|
|
2703
2746
|
version: string | null;
|
|
2704
2747
|
}>;
|
|
2705
2748
|
moves: unknown[];
|
|
2749
|
+
/** One draw per active moves block; empty when no exemplar was sampled. */
|
|
2750
|
+
sampledMoves: FieldSampledMove[];
|
|
2706
2751
|
floor?: unknown;
|
|
2707
2752
|
notices?: FieldNotice[];
|
|
2708
2753
|
storedHistoryTurns?: number;
|
|
@@ -2750,6 +2795,16 @@ type FieldConversation = {
|
|
|
2750
2795
|
/** The path of the session's record (`GET` it with the same key). */
|
|
2751
2796
|
record: string;
|
|
2752
2797
|
};
|
|
2798
|
+
/** The answer to `conversations.end`. */
|
|
2799
|
+
type FieldConversationEnd = {
|
|
2800
|
+
ok: true;
|
|
2801
|
+
/** True when an earlier end already closed the conversation. */
|
|
2802
|
+
alreadyEnded: boolean;
|
|
2803
|
+
runId: string;
|
|
2804
|
+
sessionId: string;
|
|
2805
|
+
/** The path of the session's record (`GET` it with the same key). */
|
|
2806
|
+
record: string;
|
|
2807
|
+
};
|
|
2753
2808
|
/** The answer to `turns.send`. */
|
|
2754
2809
|
type FieldTurnAnswer = {
|
|
2755
2810
|
reply: string;
|
|
@@ -2838,7 +2893,7 @@ type FieldClientOptions = {
|
|
|
2838
2893
|
/** The API host. Default `https://api.cultured.computer`. */
|
|
2839
2894
|
endpoint?: string;
|
|
2840
2895
|
};
|
|
2841
|
-
/** Options of `profiles.put`. Each overrides the
|
|
2896
|
+
/** Options of `profiles.put` and `profiles.putScene`. Each overrides the document's settings for this put. */
|
|
2842
2897
|
type FieldPutOptions = FieldRuntime & {
|
|
2843
2898
|
/** A model id that answers when the model fails before its reply started, or `none`. */
|
|
2844
2899
|
fallback?: string;
|
|
@@ -2855,6 +2910,8 @@ type FieldPutOptions = FieldRuntime & {
|
|
|
2855
2910
|
force?: boolean;
|
|
2856
2911
|
/** A conditional put: the `etag` a read or the last put answered. */
|
|
2857
2912
|
ifMatch?: string;
|
|
2913
|
+
/** Create-only with `*`: fail if the profile already exists. */
|
|
2914
|
+
ifNoneMatch?: string;
|
|
2858
2915
|
signal?: AbortSignal;
|
|
2859
2916
|
};
|
|
2860
2917
|
type FieldStartOptions = {
|
|
@@ -2877,8 +2934,17 @@ type FieldStartOptions = {
|
|
|
2877
2934
|
role: 'person' | 'assistant';
|
|
2878
2935
|
text: string;
|
|
2879
2936
|
}>;
|
|
2937
|
+
/** Explicit provenance for a scripted run, including one with no constructed opening. */
|
|
2938
|
+
constructed?: 'scripted';
|
|
2880
2939
|
/** A signed 32-bit integer; each turn sends the seed plus its index where the route takes one. */
|
|
2881
2940
|
seed?: number;
|
|
2941
|
+
/** Independent exemplar-move sampling seed; absent keeps the service's legacy behavior. */
|
|
2942
|
+
moveSeed?: number;
|
|
2943
|
+
signal?: AbortSignal;
|
|
2944
|
+
};
|
|
2945
|
+
type FieldEndOptions = {
|
|
2946
|
+
/** Your own id for the conversation, at most 200 characters. */
|
|
2947
|
+
conversation: string;
|
|
2882
2948
|
signal?: AbortSignal;
|
|
2883
2949
|
};
|
|
2884
2950
|
type FieldTurnOptions = {
|
|
@@ -2890,6 +2956,18 @@ type FieldTurnOptions = {
|
|
|
2890
2956
|
};
|
|
2891
2957
|
signal?: AbortSignal;
|
|
2892
2958
|
};
|
|
2959
|
+
type FieldTurnRequestOptions = FieldTurnOptions & {
|
|
2960
|
+
/** A UUID stable for this logical turn. Reuse it only with the same conversation, message and index. */
|
|
2961
|
+
requestId: string;
|
|
2962
|
+
/** Required request identity: the next turn index, zero on a new conversation. */
|
|
2963
|
+
resume: {
|
|
2964
|
+
turnIndex: number;
|
|
2965
|
+
};
|
|
2966
|
+
};
|
|
2967
|
+
type FieldEndpointPatchOptions = {
|
|
2968
|
+
revealsState: boolean;
|
|
2969
|
+
signal?: AbortSignal;
|
|
2970
|
+
};
|
|
2893
2971
|
type FieldSessionsOptions = {
|
|
2894
2972
|
/** Your own conversation id, exact match. */
|
|
2895
2973
|
conversation?: string;
|
|
@@ -2906,6 +2984,8 @@ type FieldClient = {
|
|
|
2906
2984
|
profiles: {
|
|
2907
2985
|
/** Put a SOUL.md at a name: creates the profile, or saves a new version or new settings. */
|
|
2908
2986
|
put(name: string, soulMarkdown: string, options?: FieldPutOptions): Promise<FieldProfilePut>;
|
|
2987
|
+
/** Put one complete scene document; a string body is sent byte for byte. */
|
|
2988
|
+
putScene(name: string, scene: FieldSceneDocument | string, options?: FieldPutOptions): Promise<FieldProfilePut>;
|
|
2909
2989
|
/** Read a profile: its live version, runtime, limits, safeguards and connection. */
|
|
2910
2990
|
get(name: string, options?: {
|
|
2911
2991
|
signal?: AbortSignal;
|
|
@@ -2913,9 +2993,15 @@ type FieldClient = {
|
|
|
2913
2993
|
/** List a profile's served sessions, newest first, one page at a time. */
|
|
2914
2994
|
sessions(name: string, options?: FieldSessionsOptions): Promise<FieldSessionsPage>;
|
|
2915
2995
|
};
|
|
2996
|
+
endpoints: {
|
|
2997
|
+
/** Change keyed endpoint configuration by the id returned on the profile read. */
|
|
2998
|
+
update(id: string, options: FieldEndpointPatchOptions): Promise<FieldProfileEndpoint>;
|
|
2999
|
+
};
|
|
2916
3000
|
conversations: {
|
|
2917
3001
|
/** Start a conversation, or answer the running one under the same id. */
|
|
2918
3002
|
start(profile: string, options: FieldStartOptions): Promise<FieldConversation>;
|
|
3003
|
+
/** End a conversation without a model call; replaying the end is safe. */
|
|
3004
|
+
end(profile: string, options: FieldEndOptions): Promise<FieldConversationEnd>;
|
|
2919
3005
|
};
|
|
2920
3006
|
turns: {
|
|
2921
3007
|
/** Serve one turn and answer it as one JSON body. Throws `FieldRefusal` when the turn fails. */
|
|
@@ -2926,6 +3012,14 @@ type FieldClient = {
|
|
|
2926
3012
|
* started arrives as an `error` frame and ends the stream.
|
|
2927
3013
|
*/
|
|
2928
3014
|
stream(profile: string, options: FieldTurnOptions): AsyncGenerator<FieldTurnFrame, void, undefined>;
|
|
3015
|
+
/** Admit one identified turn, or replay an existing receipt with the same identity. */
|
|
3016
|
+
request(profile: string, options: FieldTurnRequestOptions): Promise<FieldTurnAnswer>;
|
|
3017
|
+
/** Read only the identified turn's receipt; never admits a conversation or model call. */
|
|
3018
|
+
replay(profile: string, options: FieldTurnRequestOptions): Promise<FieldTurnAnswer>;
|
|
3019
|
+
/** The identified request as raw ordered SSE frames. */
|
|
3020
|
+
requestStream(profile: string, options: FieldTurnRequestOptions): AsyncGenerator<FieldTurnFrame, void, undefined>;
|
|
3021
|
+
/** Replay-only receipt recovery as raw ordered SSE frames. */
|
|
3022
|
+
replayStream(profile: string, options: FieldTurnRequestOptions): AsyncGenerator<FieldTurnFrame, void, undefined>;
|
|
2929
3023
|
};
|
|
2930
3024
|
sessions: {
|
|
2931
3025
|
/** Read one session's record, turn by turn. */
|
|
@@ -2940,4 +3034,4 @@ type FieldClient = {
|
|
|
2940
3034
|
*/
|
|
2941
3035
|
declare function createFieldClient(options: FieldClientOptions): FieldClient;
|
|
2942
3036
|
|
|
2943
|
-
export { type AlignmentProvenance, type CaptureTurnInput, type CapturedTurn, DEFAULT_FIELD_ENDPOINT, type EnvironmentEventInput, FIELD_REASONING_EFFORTS, FIELD_REFUSAL_CODES, type FieldClient, type FieldClientOptions, type FieldConnection, type FieldConversation, type FieldDoneFrame, type FieldEmptyCompletionReason, type FieldEndedReason, type FieldErrorFrame, type FieldEventRecord, type FieldLimits, type FieldNotice, type FieldProfile, type FieldProfileEndpoint, type FieldProfileLinks, type FieldProfilePut, type FieldProfileRuntimeSource, type FieldPutOptions, type FieldReadFrame, type FieldReasoningEffort, FieldRefusal, type FieldRefusalCode, type FieldRunFrame, type FieldRuntime, type FieldRuntimeSource, type FieldSafeguards, type FieldSessionRecord, type FieldSessionSummary, type FieldSessionTurn, type FieldSessionsOptions, type FieldSessionsPage, type FieldStartOptions, type FieldTurnAnswer, type FieldTurnFrame, type FieldTurnOptions, type FieldVersionRef, type OutcomeEventEmit, type OutcomeHook, type OutcomeResult, type PersonaConfig, Probe, type ProbeConfig, type ProbeConfigInput, SPAN_INTERVAL_KINDS, SPAN_PAYLOAD_STATES, SPAN_STATUSES, SPAN_TYPES, SPAN_V2_STATUSES, Probe as Sight, type SightAiTelemetry, type SightAiTelemetryOptions, type AlignmentProvenance as SightAlignmentProvenance, type CaptureTurnInput as SightCaptureTurnInput, type CapturedTurn as SightCapturedTurn, type ProbeConfig as SightConfig, type ProbeConfigInput as SightConfigInput, type EnvironmentEventInput as SightEnvironmentEventInput, type OutcomeEventEmit as SightOutcomeEventEmit, type OutcomeHook as SightOutcomeHook, type OutcomeResult as SightOutcomeResult, type PersonaConfig as SightPersonaConfig, type SpanInput as SightSpanInput, type SpanInputV2 as SightSpanInputV2, type SpansBatch as SightSpansBatch, type SpanInput, SpanInputSchema, type SpanInputV1, SpanInputV1Schema, type SpanInputV2, SpanInputV2Schema, type SpanInterval, type SpanIntervalKind, SpanIntervalSchema, type SpanPayload, SpanPayloadSchema, type SpanPayloadState, type SpanStatus, type SpanType, type SpansBatch, SpansBatchSchema, createFieldClient, sightTelemetry, wrapOpenAI };
|
|
3037
|
+
export { type AlignmentProvenance, type CaptureTurnInput, type CapturedTurn, DEFAULT_FIELD_ENDPOINT, type EnvironmentEventInput, FIELD_REASONING_EFFORTS, FIELD_REFUSAL_CODES, type FieldClient, type FieldClientOptions, type FieldConnection, type FieldConversation, type FieldDoneFrame, type FieldEmptyCompletionReason, type FieldEndedReason, type FieldEndpointPatchOptions, type FieldErrorFrame, type FieldEventRecord, type FieldLimits, type FieldNotice, type FieldProfile, type FieldProfileEndpoint, type FieldProfileLinks, type FieldProfilePut, type FieldProfileRuntimeSource, type FieldPutOptions, type FieldReadFrame, type FieldReasoningEffort, FieldRefusal, type FieldRefusalCode, type FieldRunFrame, type FieldRuntime, type FieldRuntimeSource, type FieldSafeguards, type FieldSceneDocument, type FieldSessionRecord, type FieldSessionSummary, type FieldSessionTurn, type FieldSessionsOptions, type FieldSessionsPage, type FieldStartOptions, type FieldTurnAnswer, type FieldTurnFrame, type FieldTurnOptions, type FieldTurnRequestOptions, type FieldVersionRef, type OutcomeEventEmit, type OutcomeHook, type OutcomeResult, type PersonaConfig, Probe, type ProbeConfig, type ProbeConfigInput, SPAN_INTERVAL_KINDS, SPAN_PAYLOAD_STATES, SPAN_STATUSES, SPAN_TYPES, SPAN_V2_STATUSES, Probe as Sight, type SightAiTelemetry, type SightAiTelemetryOptions, type AlignmentProvenance as SightAlignmentProvenance, type CaptureTurnInput as SightCaptureTurnInput, type CapturedTurn as SightCapturedTurn, type ProbeConfig as SightConfig, type ProbeConfigInput as SightConfigInput, type EnvironmentEventInput as SightEnvironmentEventInput, type OutcomeEventEmit as SightOutcomeEventEmit, type OutcomeHook as SightOutcomeHook, type OutcomeResult as SightOutcomeResult, type PersonaConfig as SightPersonaConfig, type SpanInput as SightSpanInput, type SpanInputV2 as SightSpanInputV2, type SpansBatch as SightSpansBatch, type SpanInput, SpanInputSchema, type SpanInputV1, SpanInputV1Schema, type SpanInputV2, SpanInputV2Schema, type SpanInterval, type SpanIntervalKind, SpanIntervalSchema, type SpanPayload, SpanPayloadSchema, type SpanPayloadState, type SpanStatus, type SpanType, type SpansBatch, SpansBatchSchema, createFieldClient, sightTelemetry, wrapOpenAI };
|
package/dist/index.js
CHANGED
|
@@ -3778,6 +3778,7 @@ var FIELD_REFUSAL_CODES = [
|
|
|
3778
3778
|
"revoked",
|
|
3779
3779
|
"link_inactive",
|
|
3780
3780
|
"conversation_conflict",
|
|
3781
|
+
"constructed_forbidden",
|
|
3781
3782
|
"opening_forbidden",
|
|
3782
3783
|
"opening_conflict",
|
|
3783
3784
|
"runtime_forbidden",
|
|
@@ -3954,6 +3955,7 @@ function runtimeBody(runtime) {
|
|
|
3954
3955
|
if (runtime.temperature !== void 0) out.temperature = runtime.temperature;
|
|
3955
3956
|
if (runtime.maxOutputTokens !== void 0) out.maxOutputTokens = runtime.maxOutputTokens;
|
|
3956
3957
|
if (runtime.reasoningEffort !== void 0) out.reasoningEffort = runtime.reasoningEffort;
|
|
3958
|
+
if (runtime.replyCheck !== void 0) out.replyCheck = runtime.replyCheck;
|
|
3957
3959
|
return out;
|
|
3958
3960
|
}
|
|
3959
3961
|
function createFieldClient(options) {
|
|
@@ -3984,32 +3986,51 @@ function createFieldClient(options) {
|
|
|
3984
3986
|
...input.resume ? { resume: { turnIndex: input.resume.turnIndex } } : {}
|
|
3985
3987
|
});
|
|
3986
3988
|
}
|
|
3989
|
+
function turnRequestBody(input, replayOnly) {
|
|
3990
|
+
return JSON.stringify({
|
|
3991
|
+
conversation: input.conversation,
|
|
3992
|
+
message: input.message,
|
|
3993
|
+
resume: { turnIndex: input.resume.turnIndex },
|
|
3994
|
+
requestId: input.requestId,
|
|
3995
|
+
...replayOnly ? { replayOnly: true } : {}
|
|
3996
|
+
});
|
|
3997
|
+
}
|
|
3998
|
+
async function putDocument(name, body, contentType, put) {
|
|
3999
|
+
const query = {
|
|
4000
|
+
model: put.model,
|
|
4001
|
+
temperature: put.temperature,
|
|
4002
|
+
maxOutputTokens: put.maxOutputTokens,
|
|
4003
|
+
reasoningEffort: put.reasoningEffort,
|
|
4004
|
+
replyCheck: put.replyCheck,
|
|
4005
|
+
fallback: put.fallback,
|
|
4006
|
+
consent: put.consent,
|
|
4007
|
+
safeguards: put.safeguards === void 0 ? void 0 : put.safeguards === "none" ? "none" : put.safeguards.join(","),
|
|
4008
|
+
scrub: put.scrub,
|
|
4009
|
+
idleMinutes: put.idleMinutes,
|
|
4010
|
+
turnsPerConversation: put.turnsPerConversation,
|
|
4011
|
+
conversationsPerDay: put.conversationsPerDay,
|
|
4012
|
+
dryRun: put.dryRun,
|
|
4013
|
+
force: put.force
|
|
4014
|
+
};
|
|
4015
|
+
const response = await request("PUT", `/v1/profiles/${segment(name)}${queryString(query)}`, {
|
|
4016
|
+
body,
|
|
4017
|
+
contentType,
|
|
4018
|
+
accept: "application/json",
|
|
4019
|
+
...put.ifMatch !== void 0 || put.ifNoneMatch !== void 0 ? { headers: {
|
|
4020
|
+
...put.ifMatch !== void 0 ? { "if-match": put.ifMatch } : {},
|
|
4021
|
+
...put.ifNoneMatch !== void 0 ? { "if-none-match": put.ifNoneMatch } : {}
|
|
4022
|
+
} } : {},
|
|
4023
|
+
signal: put.signal
|
|
4024
|
+
});
|
|
4025
|
+
return { ...await json(response), etag: response.headers.get("etag") };
|
|
4026
|
+
}
|
|
3987
4027
|
return {
|
|
3988
4028
|
profiles: {
|
|
3989
4029
|
async put(name, soulMarkdown, put = {}) {
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
reasoningEffort: put.reasoningEffort,
|
|
3995
|
-
fallback: put.fallback,
|
|
3996
|
-
consent: put.consent,
|
|
3997
|
-
safeguards: put.safeguards === void 0 ? void 0 : put.safeguards === "none" ? "none" : put.safeguards.join(","),
|
|
3998
|
-
scrub: put.scrub,
|
|
3999
|
-
idleMinutes: put.idleMinutes,
|
|
4000
|
-
turnsPerConversation: put.turnsPerConversation,
|
|
4001
|
-
conversationsPerDay: put.conversationsPerDay,
|
|
4002
|
-
dryRun: put.dryRun,
|
|
4003
|
-
force: put.force
|
|
4004
|
-
};
|
|
4005
|
-
const response = await request("PUT", `/v1/profiles/${segment(name)}${queryString(query)}`, {
|
|
4006
|
-
body: soulMarkdown,
|
|
4007
|
-
contentType: "text/markdown",
|
|
4008
|
-
accept: "application/json",
|
|
4009
|
-
...put.ifMatch !== void 0 ? { headers: { "if-match": put.ifMatch } } : {},
|
|
4010
|
-
signal: put.signal
|
|
4011
|
-
});
|
|
4012
|
-
return { ...await json(response), etag: response.headers.get("etag") };
|
|
4030
|
+
return putDocument(name, soulMarkdown, "text/markdown", put);
|
|
4031
|
+
},
|
|
4032
|
+
async putScene(name, scene, put = {}) {
|
|
4033
|
+
return putDocument(name, typeof scene === "string" ? scene : JSON.stringify(scene), "application/vnd.cultured.scene+json", put);
|
|
4013
4034
|
},
|
|
4014
4035
|
async get(name, get = {}) {
|
|
4015
4036
|
const response = await request("GET", `/v1/profiles/${segment(name)}`, { accept: "application/json", signal: get.signal });
|
|
@@ -4030,6 +4051,17 @@ function createFieldClient(options) {
|
|
|
4030
4051
|
return json(response);
|
|
4031
4052
|
}
|
|
4032
4053
|
},
|
|
4054
|
+
endpoints: {
|
|
4055
|
+
async update(id, update) {
|
|
4056
|
+
const response = await request("PATCH", `/v1/endpoints/${segment(id)}`, {
|
|
4057
|
+
body: JSON.stringify({ revealsState: update.revealsState }),
|
|
4058
|
+
contentType: "application/json",
|
|
4059
|
+
accept: "application/json",
|
|
4060
|
+
signal: update.signal
|
|
4061
|
+
});
|
|
4062
|
+
return json(response);
|
|
4063
|
+
}
|
|
4064
|
+
},
|
|
4033
4065
|
conversations: {
|
|
4034
4066
|
async start(profile, start) {
|
|
4035
4067
|
const body = JSON.stringify({
|
|
@@ -4037,7 +4069,9 @@ function createFieldClient(options) {
|
|
|
4037
4069
|
user: start.user,
|
|
4038
4070
|
...start.runtime !== void 0 ? { runtime: runtimeBody(start.runtime) } : {},
|
|
4039
4071
|
...start.opening !== void 0 ? { opening: start.opening } : {},
|
|
4040
|
-
...start.
|
|
4072
|
+
...start.constructed !== void 0 ? { constructed: start.constructed } : {},
|
|
4073
|
+
...start.seed !== void 0 ? { seed: start.seed } : {},
|
|
4074
|
+
...start.moveSeed !== void 0 ? { moveSeed: start.moveSeed } : {}
|
|
4041
4075
|
});
|
|
4042
4076
|
const response = await request("POST", `/v1/profiles/${segment(profile)}/conversations`, {
|
|
4043
4077
|
body,
|
|
@@ -4046,6 +4080,15 @@ function createFieldClient(options) {
|
|
|
4046
4080
|
signal: start.signal
|
|
4047
4081
|
});
|
|
4048
4082
|
return json(response);
|
|
4083
|
+
},
|
|
4084
|
+
async end(profile, end) {
|
|
4085
|
+
const response = await request("POST", `/v1/profiles/${segment(profile)}/conversations/end`, {
|
|
4086
|
+
body: JSON.stringify({ conversation: end.conversation }),
|
|
4087
|
+
contentType: "application/json",
|
|
4088
|
+
accept: "application/json",
|
|
4089
|
+
signal: end.signal
|
|
4090
|
+
});
|
|
4091
|
+
return json(response);
|
|
4049
4092
|
}
|
|
4050
4093
|
},
|
|
4051
4094
|
turns: {
|
|
@@ -4067,6 +4110,44 @@ function createFieldClient(options) {
|
|
|
4067
4110
|
});
|
|
4068
4111
|
if (!response.body) return;
|
|
4069
4112
|
yield* readFrames(response.body);
|
|
4113
|
+
},
|
|
4114
|
+
async request(profile, turn) {
|
|
4115
|
+
const response = await request("POST", `/v1/profiles/${segment(profile)}/turn-requests`, {
|
|
4116
|
+
body: turnRequestBody(turn, false),
|
|
4117
|
+
contentType: "application/json",
|
|
4118
|
+
accept: "application/json",
|
|
4119
|
+
signal: turn.signal
|
|
4120
|
+
});
|
|
4121
|
+
return json(response);
|
|
4122
|
+
},
|
|
4123
|
+
async replay(profile, turn) {
|
|
4124
|
+
const response = await request("POST", `/v1/profiles/${segment(profile)}/turn-requests`, {
|
|
4125
|
+
body: turnRequestBody(turn, true),
|
|
4126
|
+
contentType: "application/json",
|
|
4127
|
+
accept: "application/json",
|
|
4128
|
+
signal: turn.signal
|
|
4129
|
+
});
|
|
4130
|
+
return json(response);
|
|
4131
|
+
},
|
|
4132
|
+
async *requestStream(profile, turn) {
|
|
4133
|
+
const response = await request("POST", `/v1/profiles/${segment(profile)}/turn-requests`, {
|
|
4134
|
+
body: turnRequestBody(turn, false),
|
|
4135
|
+
contentType: "application/json",
|
|
4136
|
+
accept: "text/event-stream",
|
|
4137
|
+
signal: turn.signal
|
|
4138
|
+
});
|
|
4139
|
+
if (!response.body) return;
|
|
4140
|
+
yield* readFrames(response.body);
|
|
4141
|
+
},
|
|
4142
|
+
async *replayStream(profile, turn) {
|
|
4143
|
+
const response = await request("POST", `/v1/profiles/${segment(profile)}/turn-requests`, {
|
|
4144
|
+
body: turnRequestBody(turn, true),
|
|
4145
|
+
contentType: "application/json",
|
|
4146
|
+
accept: "text/event-stream",
|
|
4147
|
+
signal: turn.signal
|
|
4148
|
+
});
|
|
4149
|
+
if (!response.body) return;
|
|
4150
|
+
yield* readFrames(response.body);
|
|
4070
4151
|
}
|
|
4071
4152
|
},
|
|
4072
4153
|
sessions: {
|