@ziggy-ai/client-sdk 1.2.6 → 1.5.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.
- package/CHANGELOG.md +33 -0
- package/LICENSE +21 -21
- package/README.md +416 -398
- package/dist/agents.d.ts +0 -1
- package/dist/analytics.d.ts +0 -1
- package/dist/app-intel.d.ts +0 -1
- package/dist/app.d.ts +53 -4
- package/dist/auth.d.ts +0 -1
- package/dist/callback-handler.d.ts +48 -6
- package/dist/chat.d.ts +8 -9
- package/dist/connection.d.ts +0 -1
- package/dist/context.d.ts +0 -1
- package/dist/conversations.d.ts +9 -1
- package/dist/element-registry.d.ts +0 -1
- package/dist/errors.d.ts +0 -1
- package/dist/feedback.d.ts +0 -1
- package/dist/hooks.d.ts +0 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.js +147 -4
- package/dist/notifications.d.ts +0 -1
- package/dist/observer.d.ts +0 -1
- package/dist/persistence.d.ts +0 -1
- package/dist/product-memory.d.ts +0 -1
- package/dist/quests.d.ts +0 -1
- package/dist/screenshot-uploader.d.ts +0 -1
- package/dist/screenshot.d.ts +0 -1
- package/dist/session.d.ts +0 -1
- package/dist/signals.d.ts +0 -1
- package/dist/storage.d.ts +0 -1
- package/dist/stream-parser.d.ts +0 -1
- package/dist/styles/ziggy-highlights.css +37 -37
- package/dist/testing.d.ts +0 -1
- package/dist/tickets.d.ts +0 -1
- package/dist/tools.d.ts +0 -1
- package/dist/triggers.d.ts +0 -1
- package/dist/types.d.ts +219 -2
- package/dist/ui-actions.d.ts +0 -1
- package/dist/voice.d.ts +0 -1
- package/package.json +3 -2
- package/dist/agents.d.ts.map +0 -1
- package/dist/analytics.d.ts.map +0 -1
- package/dist/app-intel.d.ts.map +0 -1
- package/dist/app.d.ts.map +0 -1
- package/dist/auth.d.ts.map +0 -1
- package/dist/callback-handler.d.ts.map +0 -1
- package/dist/chat.d.ts.map +0 -1
- package/dist/connection.d.ts.map +0 -1
- package/dist/context.d.ts.map +0 -1
- package/dist/conversations.d.ts.map +0 -1
- package/dist/element-registry.d.ts.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/feedback.d.ts.map +0 -1
- package/dist/hooks.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/notifications.d.ts.map +0 -1
- package/dist/observer.d.ts.map +0 -1
- package/dist/persistence.d.ts.map +0 -1
- package/dist/product-memory.d.ts.map +0 -1
- package/dist/quests.d.ts.map +0 -1
- package/dist/screenshot-uploader.d.ts.map +0 -1
- package/dist/screenshot.d.ts.map +0 -1
- package/dist/session.d.ts.map +0 -1
- package/dist/signals.d.ts.map +0 -1
- package/dist/storage.d.ts.map +0 -1
- package/dist/stream-parser.d.ts.map +0 -1
- package/dist/testing.d.ts.map +0 -1
- package/dist/tickets.d.ts.map +0 -1
- package/dist/tools.d.ts.map +0 -1
- package/dist/triggers.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/ui-actions.d.ts.map +0 -1
- package/dist/voice.d.ts.map +0 -1
package/dist/agents.d.ts
CHANGED
package/dist/analytics.d.ts
CHANGED
package/dist/app-intel.d.ts
CHANGED
package/dist/app.d.ts
CHANGED
|
@@ -5,8 +5,17 @@
|
|
|
5
5
|
* (resolved server-side by auth middleware), so no appId is needed here.
|
|
6
6
|
*/
|
|
7
7
|
import type { Connection } from './connection.js';
|
|
8
|
-
import type { RegisterTriggersRequest, RegisterTriggersResponse, ListTriggersResponse, DeleteResponse, RegisterQuickActionsRequest, RegisterQuickActionsResponse, ListQuickActionsResponse, RegisterHostActionsRequest, RegisterHostActionsResponse, ListHostActionsResponse, RegisterBrandRequest, GetBrandResponse, SpokenVoiceRecommendationsResponse, SpokenVoiceConfig, SetCredentialsRequest, SetCredentialsResponse, GetCredentialsResponse, AppStatus, VerifyResponse, YoloConfig, SetYoloConfigRequest, DeploymentSettings, UpdateDeploymentSettingsRequest, TriageConfig, SetTriageConfigRequest, ToolConfig, SetToolConfigRequest, AuditTriggerResponse, ObserverConfigResponse, DesignSystemResponse, DesignTokensResponse, ComponentSpecResponse } from './types.js';
|
|
8
|
+
import type { RegisterTriggersRequest, RegisterTriggersResponse, ListTriggersResponse, DeleteResponse, RegisterQuickActionsRequest, RegisterQuickActionsResponse, ListQuickActionsResponse, RegisterHostActionsRequest, RegisterHostActionsResponse, ListHostActionsResponse, RegisterBrandRequest, OwnerProfileFields, SetProfileResponse, AddDomainConceptRequest, AddDomainConceptResponse, GetBrandResponse, PublicBrandResponse, SpokenVoiceRecommendationsResponse, SpokenVoiceConfig, SetCredentialsRequest, SetCredentialsResponse, GetCredentialsResponse, AppCallbackResponse, AppStatus, VerifyResponse, AppAvailabilityResponse, YoloConfig, SetYoloConfigRequest, DeploymentSettings, UpdateDeploymentSettingsRequest, TriageConfig, SetTriageConfigRequest, ToolConfig, SetToolConfigRequest, AuditTriggerResponse, ObserverConfigResponse, DesignSystemResponse, DesignTokensResponse, ComponentSpecResponse } from './types.js';
|
|
9
9
|
export declare class AppClient {
|
|
10
|
+
getConversationPolicy(): Promise<{
|
|
11
|
+
mode: 'support_led' | 'visible_team';
|
|
12
|
+
appliesTo: 'new_conversations';
|
|
13
|
+
}>;
|
|
14
|
+
/** Server-side app setup. Applies to new conversations; existing threads keep their policy. */
|
|
15
|
+
setConversationPolicy(mode: 'support_led' | 'visible_team'): Promise<{
|
|
16
|
+
mode: 'support_led' | 'visible_team';
|
|
17
|
+
appliesTo: 'new_conversations';
|
|
18
|
+
}>;
|
|
10
19
|
private connection;
|
|
11
20
|
constructor(connection: Connection);
|
|
12
21
|
/**
|
|
@@ -52,9 +61,17 @@ export declare class AppClient {
|
|
|
52
61
|
updated: boolean;
|
|
53
62
|
}>;
|
|
54
63
|
/**
|
|
55
|
-
*
|
|
64
|
+
* The public part of the brand profile: the name, the avatar and the main colour. It is what a chat panel
|
|
65
|
+
* draws and all this read answers, for every caller. Safe to call from a browser.
|
|
66
|
+
*/
|
|
67
|
+
getBrand(): Promise<PublicBrandResponse>;
|
|
68
|
+
/**
|
|
69
|
+
* The whole brand profile, as `setBrand` wrote it and the Brand Designer filled it in. For your server only:
|
|
70
|
+
* a request that comes through a browser proxy is refused. Read this one before you change the profile and
|
|
71
|
+
* write it back: `setBrand` replaces the profile with what it is given, and refuses the short answer of
|
|
72
|
+
* `getBrand` (409 `brand_partial_write`) because saving it would remove the rest.
|
|
56
73
|
*/
|
|
57
|
-
|
|
74
|
+
getFullBrand(): Promise<GetBrandResponse>;
|
|
58
75
|
/**
|
|
59
76
|
* Brand-informed top spoken-voice recommendations for chat TTS.
|
|
60
77
|
*/
|
|
@@ -79,6 +96,8 @@ export declare class AppClient {
|
|
|
79
96
|
/**
|
|
80
97
|
* Get the full design system (tokens + component specs).
|
|
81
98
|
* Requires brand extraction to have completed first.
|
|
99
|
+
* Through the managed browser proxy the answer is the tokens only: `components` is empty and the record's
|
|
100
|
+
* ids are left out.
|
|
82
101
|
*/
|
|
83
102
|
getDesignSystem(): Promise<DesignSystemResponse>;
|
|
84
103
|
/**
|
|
@@ -90,6 +109,22 @@ export declare class AppClient {
|
|
|
90
109
|
* Returns 404 with list of available component names if not found.
|
|
91
110
|
*/
|
|
92
111
|
getComponentSpec(name: string): Promise<ComponentSpecResponse>;
|
|
112
|
+
/**
|
|
113
|
+
* Write the App Profile. Creates a draft when the app has none, otherwise
|
|
114
|
+
* updates it. Agents use it only after approveProfile().
|
|
115
|
+
*/
|
|
116
|
+
setProfile(profile: OwnerProfileFields): Promise<SetProfileResponse>;
|
|
117
|
+
/** Approve the draft profile so agents treat it as the app's ground truth. */
|
|
118
|
+
approveProfile(): Promise<{
|
|
119
|
+
approved: boolean;
|
|
120
|
+
applied: boolean;
|
|
121
|
+
effect: string;
|
|
122
|
+
}>;
|
|
123
|
+
/**
|
|
124
|
+
* Add a product term (plan, package, policy). With approve: true Support may
|
|
125
|
+
* use it at once; otherwise it waits for approval in the Console.
|
|
126
|
+
*/
|
|
127
|
+
addDomainConcept(concept: AddDomainConceptRequest): Promise<AddDomainConceptResponse>;
|
|
93
128
|
/**
|
|
94
129
|
* Set or update tool credentials (encrypted at rest).
|
|
95
130
|
* Merges with existing credentials — pass only the ones to update.
|
|
@@ -103,6 +138,15 @@ export declare class AppClient {
|
|
|
103
138
|
* Delete all stored credentials.
|
|
104
139
|
*/
|
|
105
140
|
deleteCredentials(): Promise<DeleteResponse>;
|
|
141
|
+
/**
|
|
142
|
+
* Get the URL Ziggy POSTs host tool calls and http-executor actions to.
|
|
143
|
+
*/
|
|
144
|
+
getCallback(): Promise<AppCallbackResponse>;
|
|
145
|
+
/**
|
|
146
|
+
* Set (or clear with null) the callback URL. HTTPS only; the server refuses
|
|
147
|
+
* private, loopback, link-local and metadata destinations after DNS resolution.
|
|
148
|
+
*/
|
|
149
|
+
setCallbackUrl(callbackUrl: string | null): Promise<AppCallbackResponse>;
|
|
106
150
|
/**
|
|
107
151
|
* Get app setup status (brand, triggers, actions, agents, readiness).
|
|
108
152
|
*/
|
|
@@ -121,6 +165,12 @@ export declare class AppClient {
|
|
|
121
165
|
* Use this as a pre-flight check to confirm the SDK is configured correctly.
|
|
122
166
|
*/
|
|
123
167
|
verify(): Promise<VerifyResponse>;
|
|
168
|
+
/**
|
|
169
|
+
* Whether this app's chat answers. When it does not (the app's account has no
|
|
170
|
+
* active plan), `chat.fallback` holds what to show visitors instead. Safe to
|
|
171
|
+
* call from a browser through the managed proxy before any user is known.
|
|
172
|
+
*/
|
|
173
|
+
getAvailability(): Promise<AppAvailabilityResponse>;
|
|
124
174
|
/**
|
|
125
175
|
* Get YOLO mode configuration.
|
|
126
176
|
*/
|
|
@@ -173,4 +223,3 @@ export declare class AppClient {
|
|
|
173
223
|
*/
|
|
174
224
|
triggerAudit(): Promise<AuditTriggerResponse>;
|
|
175
225
|
}
|
|
176
|
-
//# sourceMappingURL=app.d.ts.map
|
package/dist/auth.d.ts
CHANGED
|
@@ -6,4 +6,3 @@ import type { ZiggyClientConfig } from './types.js';
|
|
|
6
6
|
* Build default headers with API key and optional auth token.
|
|
7
7
|
*/
|
|
8
8
|
export declare function buildHeaders(config: ZiggyClientConfig, extra?: Record<string, string>): Promise<Record<string, string>>;
|
|
9
|
-
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -21,13 +21,41 @@
|
|
|
21
21
|
* return { retried: true, newProcessId: transforms.latestId };
|
|
22
22
|
* });
|
|
23
23
|
*
|
|
24
|
-
* // In
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* })
|
|
24
|
+
* // In a fetch-style server (Cloudflare Worker, Hono, Next route handler):
|
|
25
|
+
* // verifies X-Ziggy-Signature with your callback secret, then dispatches.
|
|
26
|
+
* export default {
|
|
27
|
+
* fetch: (request: Request, env: { ZIGGY_CALLBACK_SECRET: string }) =>
|
|
28
|
+
* handler.handleRequest(request, { secret: env.ZIGGY_CALLBACK_SECRET }),
|
|
29
|
+
* };
|
|
29
30
|
* ```
|
|
31
|
+
*
|
|
32
|
+
* Signing scheme (same as Ziggy signal webhooks): X-Ziggy-Timestamp is an
|
|
33
|
+
* ISO 8601 UTC time; X-Ziggy-Signature is `v1=` + hex HMAC-SHA256 of
|
|
34
|
+
* `${timestamp}.${rawBody}` keyed with the app's callback secret
|
|
35
|
+
* (POST /v1/apps/callback/secret). See docs/architecture/02-api-reference.md.
|
|
30
36
|
*/
|
|
37
|
+
export declare const DEFAULT_CALLBACK_TOLERANCE_MS: number;
|
|
38
|
+
export interface VerifyCallbackOptions {
|
|
39
|
+
/** The app's callback secret (hex string from POST /v1/apps/callback/secret). */
|
|
40
|
+
secret: string;
|
|
41
|
+
/** Max allowed clock difference between the timestamp and now. Default 5 minutes. */
|
|
42
|
+
toleranceMs?: number;
|
|
43
|
+
/** Override "now" (ms since epoch), for tests. */
|
|
44
|
+
now?: number;
|
|
45
|
+
}
|
|
46
|
+
export type CallbackVerification = {
|
|
47
|
+
valid: true;
|
|
48
|
+
} | {
|
|
49
|
+
valid: false;
|
|
50
|
+
reason: 'missing_signature' | 'bad_timestamp' | 'stale_timestamp' | 'bad_signature';
|
|
51
|
+
};
|
|
52
|
+
type HeaderSource = Headers | Record<string, string | string[] | undefined>;
|
|
53
|
+
/**
|
|
54
|
+
* Verify that a callback request came from Ziggy. Pass the raw body text,
|
|
55
|
+
* exactly as received, before any JSON parsing. Uses Web Crypto, so it runs in
|
|
56
|
+
* Cloudflare Workers, Deno, browsers and Node 18+.
|
|
57
|
+
*/
|
|
58
|
+
export declare function verifyCallbackSignature(headers: HeaderSource, rawBody: string, options: VerifyCallbackOptions): Promise<CallbackVerification>;
|
|
31
59
|
export interface CallbackRequest {
|
|
32
60
|
toolId: string;
|
|
33
61
|
params: Record<string, unknown>;
|
|
@@ -56,9 +84,23 @@ export declare class CallbackHandler {
|
|
|
56
84
|
* Returns a response object suitable for sending back as JSON.
|
|
57
85
|
*/
|
|
58
86
|
handle(request: CallbackRequest): Promise<CallbackResponse>;
|
|
87
|
+
/**
|
|
88
|
+
* Verify and handle a fetch-style Request in one call. Requests without a
|
|
89
|
+
* valid X-Ziggy-Signature, or with a timestamp outside the tolerance window,
|
|
90
|
+
* get 401 and no handler runs.
|
|
91
|
+
*
|
|
92
|
+
* Fails closed: an empty or missing `secret` (for example an unset Worker
|
|
93
|
+
* binding) answers 500 and runs nothing. Pass `allowUnsigned: true` only
|
|
94
|
+
* while your app has no callback secret yet.
|
|
95
|
+
*/
|
|
96
|
+
handleRequest(request: Request, options?: {
|
|
97
|
+
secret?: string;
|
|
98
|
+
toleranceMs?: number;
|
|
99
|
+
allowUnsigned?: boolean;
|
|
100
|
+
}): Promise<Response>;
|
|
59
101
|
/**
|
|
60
102
|
* List all registered tool IDs.
|
|
61
103
|
*/
|
|
62
104
|
get registeredTools(): string[];
|
|
63
105
|
}
|
|
64
|
-
|
|
106
|
+
export {};
|
package/dist/chat.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { Connection } from './connection.js';
|
|
8
8
|
import type { SessionManager } from './session.js';
|
|
9
|
-
import type { ChatRequest, ActionRequest, ActionResponse, StreamEvent, ConversationSummary, ConversationDetail,
|
|
9
|
+
import type { ChatRequest, ActionRequest, ActionResponse, StreamEvent, ConversationSummary, ConversationDetail, ConversationMessagesPage } from './types.js';
|
|
10
10
|
export declare class ChatClient {
|
|
11
11
|
private connection;
|
|
12
12
|
private sessionManager;
|
|
@@ -74,17 +74,17 @@ export declare class ChatClient {
|
|
|
74
74
|
*/
|
|
75
75
|
getConversation(conversationId: string, limit?: number): Promise<ConversationDetail>;
|
|
76
76
|
/**
|
|
77
|
-
* Get
|
|
78
|
-
*
|
|
77
|
+
* Get one page of a conversation's messages, oldest first.
|
|
78
|
+
* No cursor: the newest page. `beforeSeq`: the page before it (load older;
|
|
79
|
+
* continue with `olderBeforeSeq`). `afterSeq`: the page after it, to poll
|
|
80
|
+
* for newer messages (ZIG-125 live operator join; continue with `nextAfterSeq`
|
|
81
|
+
* while `hasMore`). Pass one cursor, not both.
|
|
79
82
|
*/
|
|
80
83
|
getMessages(conversationId: string, options?: number | {
|
|
81
84
|
limit?: number;
|
|
82
85
|
afterSeq?: number;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
handoffStatus?: string;
|
|
86
|
-
lastSeq?: number;
|
|
87
|
-
}>;
|
|
86
|
+
beforeSeq?: number;
|
|
87
|
+
}): Promise<ConversationMessagesPage>;
|
|
88
88
|
/**
|
|
89
89
|
* List conversations for a user (scoped to current app).
|
|
90
90
|
*/
|
|
@@ -100,4 +100,3 @@ export declare class ChatClient {
|
|
|
100
100
|
};
|
|
101
101
|
}>;
|
|
102
102
|
}
|
|
103
|
-
//# sourceMappingURL=chat.d.ts.map
|
package/dist/connection.d.ts
CHANGED
package/dist/context.d.ts
CHANGED
package/dist/conversations.d.ts
CHANGED
|
@@ -8,9 +8,18 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { Connection } from './connection.js';
|
|
10
10
|
import type { RoomEvent, RoomParticipantsResponse, InviteHumanRequest, InviteHumanResponse } from './types.js';
|
|
11
|
+
import type { ConversationPartnerState, ConversationPartnerCommand } from './types.js';
|
|
11
12
|
export declare class ConversationsClient {
|
|
12
13
|
private connection;
|
|
13
14
|
constructor(connection: Connection);
|
|
15
|
+
partner(conversationId: string): Promise<ConversationPartnerState>;
|
|
16
|
+
changePartner(conversationId: string, command: ConversationPartnerCommand): Promise<{
|
|
17
|
+
receipt: {
|
|
18
|
+
revision: number;
|
|
19
|
+
replayed: boolean;
|
|
20
|
+
};
|
|
21
|
+
state: ConversationPartnerState;
|
|
22
|
+
}>;
|
|
14
23
|
/**
|
|
15
24
|
* Subscribe to the room feed. Replays events after `afterSeq`, then stays
|
|
16
25
|
* open; heartbeats arrive as `{ type: 'heartbeat', seq: -1 }`. Abort the
|
|
@@ -25,4 +34,3 @@ export declare class ConversationsClient {
|
|
|
25
34
|
/** The end user asks for a person. Idempotent while one is already requested or present. */
|
|
26
35
|
invite(conversationId: string, request?: InviteHumanRequest): Promise<InviteHumanResponse>;
|
|
27
36
|
}
|
|
28
|
-
//# sourceMappingURL=conversations.d.ts.map
|
package/dist/errors.d.ts
CHANGED
package/dist/feedback.d.ts
CHANGED
package/dist/hooks.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -134,12 +134,12 @@ export declare class ZiggyClient {
|
|
|
134
134
|
*/
|
|
135
135
|
disconnect(): Promise<void>;
|
|
136
136
|
}
|
|
137
|
-
export type { ZiggyClientConfig, CreateSessionRequest, SessionResponse, SessionExperiences, ExperienceKey, ExperienceWalkthroughStep, SessionConfig, AgentSummary, CatalogAgent, AgentListResponse, CatalogTool, AgentDetailResponse, PageContext, ProcessContext, ContentContext, UserContext, ErrorEntry, SupportContext, ContextPushRequest, ContextPushResponse, ContextEvent, ChatRequest, ChatResponse, ChatAttachment, ActionRequest, ActionResponse, Confidence, Source, ToolUsage, StreamEvent, StreamStartEvent, AgentStartEvent, AgentSwitchEvent, ToolStartEvent, ToolProgressEvent, ToolResultEvent, ContentDeltaEvent, ContentDoneEvent, MetadataEvent, StreamEndEvent, StreamErrorEvent, ToolErrorEvent, ReturnHandoffEvent, ActivityEvent, QuestStatusEvent, QuestStepUpdateEvent, QuestCompleteEvent, WalkthroughStep, UIHighlightEvent, UIScrollEvent, UIClickEvent, UITypeEvent, UIWalkthroughEvent, UINavigateEvent, UIScreenshotAnalysisEvent, UISurfaceEvent, HostActionEvent, ChatSurfaceMode, HostActionDefinition, RegisterHostActionsRequest, RegisterHostActionsResponse, ListHostActionsResponse, ScreenshotAnnotation, WalkthroughResult, BrandConfig, SpokenVoiceConfig, SpokenVoiceRecommendation, SpokenVoiceRecommendationsResponse, ProactiveTrigger, QuickAction, ToolInvokeRequest, ToolInvokeResponse, ReactionRequest, FeedbackRequest, Quest, QuestStep, TriggerCondition, TriggerRegistration, RegisterTriggersRequest, RegisterTriggersResponse, ListTriggersResponse, DeleteResponse, QuickActionSetConditions, QuickActionSet, RegisterQuickActionsRequest, RegisterQuickActionsResponse, ListQuickActionsResponse, RegisterBrandRequest, GetBrandResponse, SetCredentialsRequest, SetCredentialsResponse, GetCredentialsResponse, Ticket, CreateTicketRequest, CreateTicketResponse, UpdateTicketRequest, TicketFilters, TicketResponse, CreateTicketResponseRequest, TicketAnalysis, TimelineEvent, TicketTimeline, TicketConversation, TriageTicket, TicketPattern, MediaAttachment, RequestUploadRequest, RequestUploadResponse, ConfirmUploadResponse, UploadMediaRequest, UploadMediaResponse, VoiceTokenResponse, VoiceTtsResult, VoiceTtsAudio, VoiceTtsFallback, LiveConversationState, LiveSessionCreateRequest, LiveSessionCreateResponse, LiveSessionCloseResponse, LiveInterruptResponse, LiveSessionStatus, LiveStateEvent, LiveTranscriptEvent, LiveTurnEvent, LiveCommentaryEvent, LiveUsageEvent, LiveClosedEvent, DiscoveryJobStatus, PageType, DiscoveryJob, DiscoveredPage, AnalysisType, AnalysisIssue, AnalysisResult, SpecialistAnalysis, AppPersona, TestScenario, TestStrategy, ChangeEvent, ScreenshotConfig, ScreencastConfig, ScreencastFrame, TestRunStatus, TestResultStatus, TestRun, TestResult, StepResult, TestInsight, TriggerDiscoveryRequest, TriggerAnalysisRequest, GeneratePersonasRequest, GenerateTestScenariosRequest, GenerateTestStrategyRequest, DetectChangesRequest, CaptureScreenshotsRequest, StartTestRunRequest, AnalyzeTestRunRequest, ConversationMessage, ConversationSummary, ConversationDetail, AppStatus, VerifyResponse, YoloConfig, SetYoloConfigRequest, DeploymentSettings, UpdateDeploymentSettingsRequest, TriageConfig, SetTriageConfigRequest, ToolConfig, SetToolConfigRequest, ObservationCycle, ObservationCycleDetail, Observation, HealthScore, HealthScoreResponse, SignalsResponse, SelfTestCycle, SelfTestCycleDetail, SuiteResult, SelfTestResult, TestingBrainReport, SelfTestTrend, TriggerResponse, EngineeringJob, EngineeringProposal, ProposalDeployment, TriggerEngineeringRequest, UpdateProposalRequest, TriggerDeploymentRequest, UpdateDeploymentRequest, AuditTriggerResponse, ObserverConfigResponse, DesignTokens, ComponentSpec, DesignSystemResponse, DesignTokensResponse, ComponentSpecResponse, Notification, NotificationType, NotificationSeverity, NotificationStatus, NotificationsResponse, NotificationCountResponse, CodeChangeEvent, SignificanceLevel, StreamCollectingEvent, StreamQueuedEvent, StreamSteeringEvent, StreamInterruptedEvent, CoalesceResponse, TurnMetrics, TurnStartedEvent, TurnMetricsEvent, TurnCompletedEvent, SpanStartedEvent, SpanCompletedEvent, SpanErrorEvent, UICaptureScreenshotEvent, CrewPlanEvent, AgentDispatchedEvent, AgentProgressEvent, AgentFindingEvent, AgentCompleteEvent, CrewSynthesisEvent, CrewCompleteEvent, CrewAwaitingApprovalEvent, CrewApprovedEvent, CrewCancelledEvent, CrewStoppedEvent, AgentHandoffEvent, HookName, HookStyle, WebhookHook, CreateHookRequest, UpdateHookRequest, ListHooksResponse, InboundSignalStatus, InboundSignalOutcome, InboundSignalEnvironment, InboundSignalPriority, InboundSignalRelease, InboundSignal, CreateInboundSignalRequest, CreateInboundSignalResponse, InboundSignalFilters, InboundSignalDetailResponse, SignalAutomationMode, AutomationPolicy, SetAutomationPolicyRequest, SignalWebhookEventType, SignalWebhookSubscription, CreateSignalWebhookSubscriptionRequest, UpdateSignalWebhookSubscriptionRequest, CreateSignalWebhookSubscriptionResponse, SignalWebhookDeliveryStatus, SignalWebhookDelivery, RoomParticipantKind, RoomParticipantRole, RoomParticipantMode, RoomPresenceState, Participant, RoomEventType, RoomEvent, RoutingSignal, RoutingEvent, RoomParticipantsResponse, InviteHumanRequest, InviteHumanResponse, } from './types.js';
|
|
137
|
+
export type { RecommendationDiscussionReference, BrowserReviewDiscussionReference, ZiggyClientConfig, CreateSessionRequest, SessionResponse, SessionExperiences, ExperienceKey, ExperienceWalkthroughStep, SessionConfig, AgentSummary, CatalogAgent, AgentListResponse, CatalogTool, AgentDetailResponse, PageContext, ProcessContext, ContentContext, UserContext, ErrorEntry, SupportContext, ContextPushRequest, ContextPushResponse, ContextEvent, ChatRequest, ChatResponse, ChatAttachment, ActionRequest, ActionResponse, Confidence, Source, ToolUsage, StreamEvent, StreamStartEvent, AgentStartEvent, AgentSwitchEvent, ToolStartEvent, ToolProgressEvent, ToolResultEvent, ContentDeltaEvent, ContentDoneEvent, MetadataEvent, StreamEndEvent, StreamErrorEvent, ToolErrorEvent, ReturnHandoffEvent, ActivityEvent, QuestStatusEvent, QuestStepUpdateEvent, QuestCompleteEvent, WalkthroughStep, UIHighlightEvent, UIScrollEvent, UIClickEvent, UITypeEvent, UIWalkthroughEvent, UINavigateEvent, UIScreenshotAnalysisEvent, UISurfaceEvent, HostActionEvent, ChatSurfaceMode, HostActionDefinition, RegisterHostActionsRequest, RegisterHostActionsResponse, ListHostActionsResponse, ScreenshotAnnotation, WalkthroughResult, BrandConfig, SpokenVoiceConfig, SpokenVoiceRecommendation, SpokenVoiceRecommendationsResponse, ProactiveTrigger, QuickAction, ToolInvokeRequest, ToolInvokeResponse, ReactionRequest, FeedbackRequest, Quest, QuestStep, TriggerCondition, TriggerRegistration, RegisterTriggersRequest, RegisterTriggersResponse, ListTriggersResponse, DeleteResponse, QuickActionSetConditions, QuickActionSet, RegisterQuickActionsRequest, RegisterQuickActionsResponse, ListQuickActionsResponse, RegisterBrandRequest, OwnerProfileFields, SetProfileResponse, AddDomainConceptRequest, AddDomainConceptResponse, GetBrandResponse, PublicBrandResponse, SetCredentialsRequest, SetCredentialsResponse, GetCredentialsResponse, AppCallbackResponse, Ticket, CreateTicketRequest, CreateTicketResponse, UpdateTicketRequest, TicketFilters, TicketResponse, CreateTicketResponseRequest, TicketAnalysis, TimelineEvent, TicketTimeline, TicketConversation, TriageTicket, TicketPattern, MediaAttachment, RequestUploadRequest, RequestUploadResponse, ConfirmUploadResponse, UploadMediaRequest, UploadMediaResponse, VoiceTokenResponse, VoiceTtsResult, VoiceTtsAudio, VoiceTtsFallback, LiveConversationState, LiveSessionCreateRequest, LiveSessionCreateResponse, LiveSessionCloseResponse, LiveInterruptResponse, LiveSessionStatus, LiveStateEvent, LiveTranscriptEvent, LiveTurnEvent, LiveCommentaryEvent, LiveUsageEvent, LiveClosedEvent, DiscoveryJobStatus, PageType, DiscoveryJob, DiscoveredPage, AnalysisType, AnalysisIssue, AnalysisResult, SpecialistAnalysis, AppPersona, TestScenario, TestStrategy, ChangeEvent, ScreenshotConfig, ScreencastConfig, ScreencastFrame, TestRunStatus, TestResultStatus, TestRun, TestResult, StepResult, TestInsight, TriggerDiscoveryRequest, TriggerAnalysisRequest, GeneratePersonasRequest, GenerateTestScenariosRequest, GenerateTestStrategyRequest, DetectChangesRequest, CaptureScreenshotsRequest, StartTestRunRequest, AnalyzeTestRunRequest, ConversationPartnerState, ConversationPartnerCommand, ConversationMessage, ConversationSummary, ConversationDetail, ConversationMessagesPage, AppStatus, VerifyResponse, AppAvailabilityResponse, AppPlanState, ChatAvailability, ChatFallback, YoloConfig, SetYoloConfigRequest, DeploymentSettings, UpdateDeploymentSettingsRequest, TriageConfig, SetTriageConfigRequest, ToolConfig, SetToolConfigRequest, ObservationCycle, ObservationCycleDetail, Observation, HealthScore, HealthScoreResponse, SignalsResponse, SelfTestCycle, SelfTestCycleDetail, SuiteResult, SelfTestResult, TestingBrainReport, SelfTestTrend, TriggerResponse, EngineeringJob, EngineeringProposal, ProposalDeployment, TriggerEngineeringRequest, UpdateProposalRequest, TriggerDeploymentRequest, UpdateDeploymentRequest, AuditTriggerResponse, ObserverConfigResponse, DesignTokens, ComponentSpec, DesignSystemResponse, DesignTokensResponse, ComponentSpecResponse, Notification, NotificationType, NotificationSeverity, NotificationStatus, NotificationsResponse, NotificationCountResponse, CodeChangeEvent, SignificanceLevel, StreamCollectingEvent, StreamQueuedEvent, StreamSteeringEvent, StreamInterruptedEvent, CoalesceResponse, TurnMetrics, TurnStartedEvent, TurnMetricsEvent, TurnCompletedEvent, SpanStartedEvent, SpanCompletedEvent, SpanErrorEvent, UICaptureScreenshotEvent, CrewPlanEvent, AgentDispatchedEvent, AgentProgressEvent, AgentFindingEvent, AgentCompleteEvent, CrewSynthesisEvent, CrewCompleteEvent, CrewAwaitingApprovalEvent, CrewApprovedEvent, CrewCancelledEvent, CrewStoppedEvent, AgentHandoffEvent, HookName, HookStyle, WebhookHook, CreateHookRequest, UpdateHookRequest, ListHooksResponse, InboundSignalStatus, InboundSignalOutcome, InboundSignalEnvironment, InboundSignalPriority, InboundSignalRelease, InboundSignal, CreateInboundSignalRequest, CreateInboundSignalResponse, InboundSignalFilters, InboundSignalDetailResponse, SignalAutomationMode, AutomationPolicy, SetAutomationPolicyRequest, SignalWebhookEventType, SignalWebhookSubscription, CreateSignalWebhookSubscriptionRequest, UpdateSignalWebhookSubscriptionRequest, CreateSignalWebhookSubscriptionResponse, SignalWebhookDeliveryStatus, SignalWebhookDelivery, RoomParticipantKind, RoomParticipantRole, RoomParticipantMode, RoomPresenceState, Participant, RoomEventType, RoomEvent, RoutingSignal, ReclaimSignal, RoutingEvent, RoomParticipantsResponse, InviteHumanRequest, InviteHumanResponse, } from './types.js';
|
|
138
138
|
export { ZiggyError, ZiggyConnectionError } from './errors.js';
|
|
139
139
|
export { LocalStoragePersistence } from './persistence.js';
|
|
140
140
|
export type { PersistenceAdapter } from './persistence.js';
|
|
141
141
|
export { parseNdjsonStream, SequenceTracker } from './stream-parser.js';
|
|
142
|
-
export { CallbackHandler } from './callback-handler.js';
|
|
142
|
+
export { CallbackHandler, verifyCallbackSignature, DEFAULT_CALLBACK_TOLERANCE_MS } from './callback-handler.js';
|
|
143
143
|
export { ObserverClient } from './observer.js';
|
|
144
144
|
export { NotificationClient } from './notifications.js';
|
|
145
145
|
export { TestingClient } from './testing.js';
|
|
@@ -148,7 +148,7 @@ export { TriggerClient } from './triggers.js';
|
|
|
148
148
|
export { SignalClient } from './signals.js';
|
|
149
149
|
export { ConversationsClient } from './conversations.js';
|
|
150
150
|
export type { TriggerInteraction } from './triggers.js';
|
|
151
|
-
export type { CallbackRequest, CallbackResponse, ToolHandler } from './callback-handler.js';
|
|
151
|
+
export type { CallbackRequest, CallbackResponse, ToolHandler, VerifyCallbackOptions, CallbackVerification } from './callback-handler.js';
|
|
152
152
|
export { UIActionExecutor } from './ui-actions.js';
|
|
153
153
|
export type { UIActionExecutorConfig } from './ui-actions.js';
|
|
154
154
|
export { ElementRegistry } from './element-registry.js';
|
|
@@ -159,4 +159,3 @@ export { captureAndUpload } from './screenshot-uploader.js';
|
|
|
159
159
|
export type { ScreenshotUploadResult } from './screenshot-uploader.js';
|
|
160
160
|
export { PRODUCT_MEMORY_EVENT_TYPES, PRODUCT_FRICTION_KINDS, PRODUCT_SIGNAL_PREF_KEYS, isProductMemoryEventType, } from './product-memory.js';
|
|
161
161
|
export type { ProductMemoryEventType, ProductFrictionKind, ProductOutcomePayload, ProductSignalPrefKey, ProductMemoryPreferences, } from './product-memory.js';
|
|
162
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -464,14 +464,18 @@ var ChatClient = class {
|
|
|
464
464
|
return this.connection.request("GET", `/conversations/${conversationId}${params}`);
|
|
465
465
|
}
|
|
466
466
|
/**
|
|
467
|
-
* Get
|
|
468
|
-
*
|
|
467
|
+
* Get one page of a conversation's messages, oldest first.
|
|
468
|
+
* No cursor: the newest page. `beforeSeq`: the page before it (load older;
|
|
469
|
+
* continue with `olderBeforeSeq`). `afterSeq`: the page after it, to poll
|
|
470
|
+
* for newer messages (ZIG-125 live operator join; continue with `nextAfterSeq`
|
|
471
|
+
* while `hasMore`). Pass one cursor, not both.
|
|
469
472
|
*/
|
|
470
473
|
async getMessages(conversationId, options) {
|
|
471
474
|
const opts = typeof options === "number" ? { limit: options } : options || {};
|
|
472
475
|
const params = new URLSearchParams();
|
|
473
476
|
if (opts.limit !== void 0) params.set("limit", String(opts.limit));
|
|
474
477
|
if (opts.afterSeq !== void 0) params.set("afterSeq", String(opts.afterSeq));
|
|
478
|
+
if (opts.beforeSeq !== void 0) params.set("beforeSeq", String(opts.beforeSeq));
|
|
475
479
|
const qs = params.toString() ? `?${params.toString()}` : "";
|
|
476
480
|
return this.connection.request("GET", `/conversations/${conversationId}/messages${qs}`);
|
|
477
481
|
}
|
|
@@ -987,6 +991,13 @@ var AnalyticsClient = class {
|
|
|
987
991
|
|
|
988
992
|
// src/app.ts
|
|
989
993
|
var AppClient = class {
|
|
994
|
+
async getConversationPolicy() {
|
|
995
|
+
return this.connection.request("GET", "/apps/conversation-policy");
|
|
996
|
+
}
|
|
997
|
+
/** Server-side app setup. Applies to new conversations; existing threads keep their policy. */
|
|
998
|
+
async setConversationPolicy(mode) {
|
|
999
|
+
return this.connection.request("PUT", "/apps/conversation-policy", { mode });
|
|
1000
|
+
}
|
|
990
1001
|
connection;
|
|
991
1002
|
constructor(connection) {
|
|
992
1003
|
this.connection = connection;
|
|
@@ -1056,11 +1067,21 @@ var AppClient = class {
|
|
|
1056
1067
|
return this.connection.request("PUT", "/apps/brand", brand);
|
|
1057
1068
|
}
|
|
1058
1069
|
/**
|
|
1059
|
-
*
|
|
1070
|
+
* The public part of the brand profile: the name, the avatar and the main colour. It is what a chat panel
|
|
1071
|
+
* draws and all this read answers, for every caller. Safe to call from a browser.
|
|
1060
1072
|
*/
|
|
1061
1073
|
async getBrand() {
|
|
1062
1074
|
return this.connection.request("GET", "/apps/brand");
|
|
1063
1075
|
}
|
|
1076
|
+
/**
|
|
1077
|
+
* The whole brand profile, as `setBrand` wrote it and the Brand Designer filled it in. For your server only:
|
|
1078
|
+
* a request that comes through a browser proxy is refused. Read this one before you change the profile and
|
|
1079
|
+
* write it back: `setBrand` replaces the profile with what it is given, and refuses the short answer of
|
|
1080
|
+
* `getBrand` (409 `brand_partial_write`) because saving it would remove the rest.
|
|
1081
|
+
*/
|
|
1082
|
+
async getFullBrand() {
|
|
1083
|
+
return this.connection.request("GET", "/apps/brand/full");
|
|
1084
|
+
}
|
|
1064
1085
|
/**
|
|
1065
1086
|
* Brand-informed top spoken-voice recommendations for chat TTS.
|
|
1066
1087
|
*/
|
|
@@ -1094,6 +1115,8 @@ var AppClient = class {
|
|
|
1094
1115
|
/**
|
|
1095
1116
|
* Get the full design system (tokens + component specs).
|
|
1096
1117
|
* Requires brand extraction to have completed first.
|
|
1118
|
+
* Through the managed browser proxy the answer is the tokens only: `components` is empty and the record's
|
|
1119
|
+
* ids are left out.
|
|
1097
1120
|
*/
|
|
1098
1121
|
async getDesignSystem() {
|
|
1099
1122
|
return this.connection.request("GET", "/branding/design-system");
|
|
@@ -1111,6 +1134,25 @@ var AppClient = class {
|
|
|
1111
1134
|
async getComponentSpec(name) {
|
|
1112
1135
|
return this.connection.request("GET", `/branding/design-system/component/${encodeURIComponent(name)}`);
|
|
1113
1136
|
}
|
|
1137
|
+
// ─── Product knowledge (App Profile + domain terms) ────────────────────────
|
|
1138
|
+
/**
|
|
1139
|
+
* Write the App Profile. Creates a draft when the app has none, otherwise
|
|
1140
|
+
* updates it. Agents use it only after approveProfile().
|
|
1141
|
+
*/
|
|
1142
|
+
async setProfile(profile) {
|
|
1143
|
+
return this.connection.request("PUT", "/app-profile", profile);
|
|
1144
|
+
}
|
|
1145
|
+
/** Approve the draft profile so agents treat it as the app's ground truth. */
|
|
1146
|
+
async approveProfile() {
|
|
1147
|
+
return this.connection.request("POST", "/app-profile/approve");
|
|
1148
|
+
}
|
|
1149
|
+
/**
|
|
1150
|
+
* Add a product term (plan, package, policy). With approve: true Support may
|
|
1151
|
+
* use it at once; otherwise it waits for approval in the Console.
|
|
1152
|
+
*/
|
|
1153
|
+
async addDomainConcept(concept) {
|
|
1154
|
+
return this.connection.request("POST", "/apps/domain-research/concepts", concept);
|
|
1155
|
+
}
|
|
1114
1156
|
// ─── Credentials ────────────────────────────────────────────────────────────
|
|
1115
1157
|
/**
|
|
1116
1158
|
* Set or update tool credentials (encrypted at rest).
|
|
@@ -1131,6 +1173,20 @@ var AppClient = class {
|
|
|
1131
1173
|
async deleteCredentials() {
|
|
1132
1174
|
return this.connection.request("DELETE", "/apps/credentials");
|
|
1133
1175
|
}
|
|
1176
|
+
// ─── Callback URL ───────────────────────────────────────────────────────────
|
|
1177
|
+
/**
|
|
1178
|
+
* Get the URL Ziggy POSTs host tool calls and http-executor actions to.
|
|
1179
|
+
*/
|
|
1180
|
+
async getCallback() {
|
|
1181
|
+
return this.connection.request("GET", "/apps/callback");
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1184
|
+
* Set (or clear with null) the callback URL. HTTPS only; the server refuses
|
|
1185
|
+
* private, loopback, link-local and metadata destinations after DNS resolution.
|
|
1186
|
+
*/
|
|
1187
|
+
async setCallbackUrl(callbackUrl) {
|
|
1188
|
+
return this.connection.request("PUT", "/apps/callback", { callbackUrl });
|
|
1189
|
+
}
|
|
1134
1190
|
// ─── Status ─────────────────────────────────────────────────────────────────
|
|
1135
1191
|
/**
|
|
1136
1192
|
* Get app setup status (brand, triggers, actions, agents, readiness).
|
|
@@ -1152,6 +1208,14 @@ var AppClient = class {
|
|
|
1152
1208
|
async verify() {
|
|
1153
1209
|
return this.connection.request("GET", "/apps/verify");
|
|
1154
1210
|
}
|
|
1211
|
+
/**
|
|
1212
|
+
* Whether this app's chat answers. When it does not (the app's account has no
|
|
1213
|
+
* active plan), `chat.fallback` holds what to show visitors instead. Safe to
|
|
1214
|
+
* call from a browser through the managed proxy before any user is known.
|
|
1215
|
+
*/
|
|
1216
|
+
async getAvailability() {
|
|
1217
|
+
return this.connection.request("GET", "/apps/availability");
|
|
1218
|
+
}
|
|
1155
1219
|
// ─── YOLO Mode ──────────────────────────────────────────────────────────────
|
|
1156
1220
|
/**
|
|
1157
1221
|
* Get YOLO mode configuration.
|
|
@@ -1557,6 +1621,46 @@ var VoiceClient = class {
|
|
|
1557
1621
|
};
|
|
1558
1622
|
|
|
1559
1623
|
// src/callback-handler.ts
|
|
1624
|
+
var DEFAULT_CALLBACK_TOLERANCE_MS = 5 * 60 * 1e3;
|
|
1625
|
+
function headerValue(headers, name) {
|
|
1626
|
+
if (typeof headers.get === "function") return headers.get(name) ?? void 0;
|
|
1627
|
+
const record = headers;
|
|
1628
|
+
const key = Object.keys(record).find((k) => k.toLowerCase() === name.toLowerCase());
|
|
1629
|
+
const value = key ? record[key] : void 0;
|
|
1630
|
+
return Array.isArray(value) ? value[0] : value;
|
|
1631
|
+
}
|
|
1632
|
+
function jsonResponse(body, init = {}) {
|
|
1633
|
+
return new Response(JSON.stringify(body), { status: init.status ?? 200, headers: { "Content-Type": "application/json" } });
|
|
1634
|
+
}
|
|
1635
|
+
function toHex(bytes) {
|
|
1636
|
+
return Array.from(new Uint8Array(bytes), (b) => b.toString(16).padStart(2, "0")).join("");
|
|
1637
|
+
}
|
|
1638
|
+
function constantTimeEqual(a, b) {
|
|
1639
|
+
let diff = a.length ^ b.length;
|
|
1640
|
+
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
|
1641
|
+
diff |= (a.charCodeAt(i) || 0) ^ (b.charCodeAt(i) || 0);
|
|
1642
|
+
}
|
|
1643
|
+
return diff === 0;
|
|
1644
|
+
}
|
|
1645
|
+
async function verifyCallbackSignature(headers, rawBody, options) {
|
|
1646
|
+
const timestamp = headerValue(headers, "x-ziggy-timestamp");
|
|
1647
|
+
const signature = headerValue(headers, "x-ziggy-signature");
|
|
1648
|
+
if (!timestamp || !signature) return { valid: false, reason: "missing_signature" };
|
|
1649
|
+
const sentAt = Date.parse(timestamp);
|
|
1650
|
+
if (Number.isNaN(sentAt)) return { valid: false, reason: "bad_timestamp" };
|
|
1651
|
+
const tolerance = options.toleranceMs ?? DEFAULT_CALLBACK_TOLERANCE_MS;
|
|
1652
|
+
if (Math.abs((options.now ?? Date.now()) - sentAt) > tolerance) return { valid: false, reason: "stale_timestamp" };
|
|
1653
|
+
const encoder = new TextEncoder();
|
|
1654
|
+
const key = await crypto.subtle.importKey(
|
|
1655
|
+
"raw",
|
|
1656
|
+
encoder.encode(options.secret),
|
|
1657
|
+
{ name: "HMAC", hash: "SHA-256" },
|
|
1658
|
+
false,
|
|
1659
|
+
["sign"]
|
|
1660
|
+
);
|
|
1661
|
+
const expected = `v1=${toHex(await crypto.subtle.sign("HMAC", key, encoder.encode(`${timestamp}.${rawBody}`)))}`;
|
|
1662
|
+
return constantTimeEqual(expected, signature.trim()) ? { valid: true } : { valid: false, reason: "bad_signature" };
|
|
1663
|
+
}
|
|
1560
1664
|
var CallbackHandler = class {
|
|
1561
1665
|
handlers = /* @__PURE__ */ new Map();
|
|
1562
1666
|
/**
|
|
@@ -1598,6 +1702,37 @@ var CallbackHandler = class {
|
|
|
1598
1702
|
};
|
|
1599
1703
|
}
|
|
1600
1704
|
}
|
|
1705
|
+
/**
|
|
1706
|
+
* Verify and handle a fetch-style Request in one call. Requests without a
|
|
1707
|
+
* valid X-Ziggy-Signature, or with a timestamp outside the tolerance window,
|
|
1708
|
+
* get 401 and no handler runs.
|
|
1709
|
+
*
|
|
1710
|
+
* Fails closed: an empty or missing `secret` (for example an unset Worker
|
|
1711
|
+
* binding) answers 500 and runs nothing. Pass `allowUnsigned: true` only
|
|
1712
|
+
* while your app has no callback secret yet.
|
|
1713
|
+
*/
|
|
1714
|
+
async handleRequest(request, options = {}) {
|
|
1715
|
+
if (request.method !== "POST") return jsonResponse({ error: "Method not allowed" }, { status: 405 });
|
|
1716
|
+
const secret = options.secret?.trim() || "";
|
|
1717
|
+
if (!secret && options.allowUnsigned !== true) {
|
|
1718
|
+
return jsonResponse({ error: "Callback secret is not configured" }, { status: 500 });
|
|
1719
|
+
}
|
|
1720
|
+
const rawBody = await request.text();
|
|
1721
|
+
if (secret) {
|
|
1722
|
+
const verification = await verifyCallbackSignature(request.headers, rawBody, {
|
|
1723
|
+
secret,
|
|
1724
|
+
toleranceMs: options.toleranceMs
|
|
1725
|
+
});
|
|
1726
|
+
if (!verification.valid) return jsonResponse({ error: "Invalid signature", reason: verification.reason }, { status: 401 });
|
|
1727
|
+
}
|
|
1728
|
+
let parsed;
|
|
1729
|
+
try {
|
|
1730
|
+
parsed = JSON.parse(rawBody);
|
|
1731
|
+
} catch {
|
|
1732
|
+
return jsonResponse({ error: "Invalid JSON" }, { status: 400 });
|
|
1733
|
+
}
|
|
1734
|
+
return jsonResponse(await this.handle(parsed));
|
|
1735
|
+
}
|
|
1601
1736
|
/**
|
|
1602
1737
|
* List all registered tool IDs.
|
|
1603
1738
|
*/
|
|
@@ -1983,6 +2118,12 @@ var ConversationsClient = class {
|
|
|
1983
2118
|
constructor(connection) {
|
|
1984
2119
|
this.connection = connection;
|
|
1985
2120
|
}
|
|
2121
|
+
async partner(conversationId) {
|
|
2122
|
+
return this.connection.request("GET", `/conversations/${encodeURIComponent(conversationId)}/partner`);
|
|
2123
|
+
}
|
|
2124
|
+
async changePartner(conversationId, command) {
|
|
2125
|
+
return this.connection.request("POST", `/conversations/${encodeURIComponent(conversationId)}/partner`, command);
|
|
2126
|
+
}
|
|
1986
2127
|
/**
|
|
1987
2128
|
* Subscribe to the room feed. Replays events after `afterSeq`, then stays
|
|
1988
2129
|
* open; heartbeats arrive as `{ type: 'heartbeat', seq: -1 }`. Abort the
|
|
@@ -2465,6 +2606,7 @@ var ZiggyClient = class {
|
|
|
2465
2606
|
export {
|
|
2466
2607
|
CallbackHandler,
|
|
2467
2608
|
ConversationsClient,
|
|
2609
|
+
DEFAULT_CALLBACK_TOLERANCE_MS,
|
|
2468
2610
|
ElementRegistry,
|
|
2469
2611
|
HookClient,
|
|
2470
2612
|
LocalStoragePersistence,
|
|
@@ -2484,5 +2626,6 @@ export {
|
|
|
2484
2626
|
ZiggyError,
|
|
2485
2627
|
captureAndUpload,
|
|
2486
2628
|
isProductMemoryEventType,
|
|
2487
|
-
parseNdjsonStream
|
|
2629
|
+
parseNdjsonStream,
|
|
2630
|
+
verifyCallbackSignature
|
|
2488
2631
|
};
|
package/dist/notifications.d.ts
CHANGED
package/dist/observer.d.ts
CHANGED
package/dist/persistence.d.ts
CHANGED
|
@@ -21,4 +21,3 @@ export declare class LocalStoragePersistence implements PersistenceAdapter {
|
|
|
21
21
|
}
|
|
22
22
|
/** Build a namespaced storage key for a given app + user. */
|
|
23
23
|
export declare function persistenceKey(appId: string, userId: string, field: string): string;
|
|
24
|
-
//# sourceMappingURL=persistence.d.ts.map
|
package/dist/product-memory.d.ts
CHANGED
package/dist/quests.d.ts
CHANGED
|
@@ -24,4 +24,3 @@ export interface ScreenshotUploadResult {
|
|
|
24
24
|
* Returns an attachment ID ready to include in a chat message.
|
|
25
25
|
*/
|
|
26
26
|
export declare function captureAndUpload(storage: StorageClient, capture: ScreenshotCapture, userId: string, options?: ScreenshotOptions): Promise<ScreenshotUploadResult>;
|
|
27
|
-
//# sourceMappingURL=screenshot-uploader.d.ts.map
|
package/dist/screenshot.d.ts
CHANGED
package/dist/session.d.ts
CHANGED
package/dist/signals.d.ts
CHANGED