@ziggs-ai/api-client 0.14.2 → 0.14.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.
|
@@ -25,7 +25,7 @@ export function presentClaimResult(agreement, kind, env) {
|
|
|
25
25
|
}
|
|
26
26
|
if (agreement?.status !== 'active') {
|
|
27
27
|
const held = (agreement?.approvals ?? []).find((a) => a.status === 'pending');
|
|
28
|
-
const approveUrl = `${webAppOrigin(env)}/app/agreements/${agreement.agreementId}`;
|
|
28
|
+
const approveUrl = `${webAppOrigin(env)}/app/work/agreements/${agreement.agreementId}`;
|
|
29
29
|
const remedy = held?.heldReason === 'contact-basis'
|
|
30
30
|
? 'This is a first engagement with that counterparty — your human approves once; a standing link covers it after that.'
|
|
31
31
|
: 'Claiming for a job your human already approved activates at once — name the job with mandateAgreementId.';
|
|
@@ -30,12 +30,22 @@ export const openConversationCapability = {
|
|
|
30
30
|
'call without this still returns the original. Leave unset to continue where ' +
|
|
31
31
|
'you left off.',
|
|
32
32
|
},
|
|
33
|
+
agreementId: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
description: 'The hire this open is the working room for. On a store-claim kickoff, pass the ' +
|
|
36
|
+
'claimed agreement id so the payer is stamped from-start in that room.',
|
|
37
|
+
},
|
|
33
38
|
},
|
|
34
39
|
needsAgentId: true,
|
|
35
40
|
handler: async (args, env) => {
|
|
36
41
|
if (!args['participantId'])
|
|
37
42
|
throw new Error('participantId is required');
|
|
38
|
-
const { chatId, reused } = await openConversation(args['participantId'], fullCreds(env), {
|
|
43
|
+
const { chatId, reused } = await openConversation(args['participantId'], fullCreds(env), {
|
|
44
|
+
newChat: args['newChat'] === true,
|
|
45
|
+
...(typeof args['agreementId'] === 'string' && args['agreementId']
|
|
46
|
+
? { agreementId: args['agreementId'] }
|
|
47
|
+
: {}),
|
|
48
|
+
});
|
|
39
49
|
const lister = env.surface === 'mcp' ? 'ziggs_grant_list' : 'grant_list';
|
|
40
50
|
const grantNote = `Opening the room issued you a grant on it, so the chat also appears in ${lister} scopeKind=chat for context reads.`;
|
|
41
51
|
// word the note from the outcome instead of covering both cases.
|
|
@@ -9,8 +9,9 @@ export interface ChatSummary {
|
|
|
9
9
|
orgId: string | null;
|
|
10
10
|
isOrgChat: boolean;
|
|
11
11
|
}
|
|
12
|
-
export declare function openConversation(participantId: string, creds: Creds, { newChat }?: {
|
|
12
|
+
export declare function openConversation(participantId: string, creds: Creds, { newChat, agreementId }?: {
|
|
13
13
|
newChat?: boolean;
|
|
14
|
+
agreementId?: string;
|
|
14
15
|
}): Promise<{
|
|
15
16
|
chatId: string;
|
|
16
17
|
reused?: boolean;
|
|
@@ -91,6 +92,7 @@ export declare class ChatClient {
|
|
|
91
92
|
constructor(operatorKey: string, agentId?: string);
|
|
92
93
|
open(participantId: string, opts?: {
|
|
93
94
|
newChat?: boolean;
|
|
95
|
+
agreementId?: string;
|
|
94
96
|
}): Promise<{
|
|
95
97
|
chatId: string;
|
|
96
98
|
reused?: boolean;
|
package/dist/http/ChatClient.js
CHANGED
|
@@ -17,7 +17,7 @@ function assertCreds(creds, op) {
|
|
|
17
17
|
if (!creds?.agentId)
|
|
18
18
|
throw new Error(`agentId is required for ${op}`);
|
|
19
19
|
}
|
|
20
|
-
export async function openConversation(participantId, creds, { newChat = false } = {}) {
|
|
20
|
+
export async function openConversation(participantId, creds, { newChat = false, agreementId } = {}) {
|
|
21
21
|
if (!participantId)
|
|
22
22
|
throw new Error('participantId is required for openConversation');
|
|
23
23
|
assertCreds(creds, 'open conversation');
|
|
@@ -26,7 +26,11 @@ export async function openConversation(participantId, creds, { newChat = false }
|
|
|
26
26
|
headers: buildHeaders(creds),
|
|
27
27
|
// Only sent when asked for: an older backend ignores the field, so a
|
|
28
28
|
// caller that never wants a separate room behaves identically either way.
|
|
29
|
-
body: JSON.stringify({
|
|
29
|
+
body: JSON.stringify({
|
|
30
|
+
participantId,
|
|
31
|
+
...(newChat ? { newChat: true } : {}),
|
|
32
|
+
...(agreementId ? { agreementId } : {}),
|
|
33
|
+
}),
|
|
30
34
|
});
|
|
31
35
|
if (!res.ok) {
|
|
32
36
|
const body = await res.text().catch(() => '');
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which process is calling GET /inbox.
|
|
3
|
+
*
|
|
4
|
+
* The exclusive-read claimant must be the *host* (this fleet task, a
|
|
5
|
+
* laptop fleet, an MCP process), not the API process. Two fleets share
|
|
6
|
+
* one backend task, so stamping the API's identity would let both wake.
|
|
7
|
+
*
|
|
8
|
+
* `ecs:<id>` on Fargate, `local:<host>:<pid>` otherwise. Env-derived
|
|
9
|
+
* and memoized.
|
|
10
|
+
*/
|
|
1
11
|
export declare const INBOX_HOST_CLAIMANT_HEADER = "X-Ziggs-Instance";
|
|
2
12
|
export declare function instanceIdentity(): string;
|
|
3
13
|
/** Test seam: forget the memoized value so a case can set different env. */
|
package/dist/instanceIdentity.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { hostname } from 'node:os';
|
|
2
1
|
/**
|
|
3
2
|
* Which process is calling GET /inbox.
|
|
4
3
|
*
|
|
@@ -36,7 +35,19 @@ function resolve() {
|
|
|
36
35
|
}
|
|
37
36
|
function safeHostname() {
|
|
38
37
|
try {
|
|
39
|
-
|
|
38
|
+
// Reached for at call time, not imported at the top of the file. A static
|
|
39
|
+
// `node:os` specifier makes this module — and through the inbox client,
|
|
40
|
+
// the package entry — unresolvable to a bundler with no node builtins,
|
|
41
|
+
// which is every mobile bundler. Nothing here needs the host name in order
|
|
42
|
+
// to load.
|
|
43
|
+
//
|
|
44
|
+
// `getBuiltinModule` arrived in Node 20.16 / 22.3. On anything older the
|
|
45
|
+
// name falls back below, which costs a host label on a dev machine and
|
|
46
|
+
// nothing in a deployed task: those resolve through the container
|
|
47
|
+
// metadata path above.
|
|
48
|
+
const load = process.getBuiltinModule;
|
|
49
|
+
const os = load?.('node:os');
|
|
50
|
+
return os?.hostname?.() || 'unknown-host';
|
|
40
51
|
}
|
|
41
52
|
catch {
|
|
42
53
|
return 'unknown-host';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ziggs-ai/api-client",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.3",
|
|
4
4
|
"description": "HTTP and WebSocket client for the Ziggs backend API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,11 +15,6 @@
|
|
|
15
15
|
"types": "./dist/http/index.d.ts",
|
|
16
16
|
"import": "./dist/http/index.js",
|
|
17
17
|
"default": "./dist/http/index.js"
|
|
18
|
-
},
|
|
19
|
-
"./websocket": {
|
|
20
|
-
"types": "./dist/websocket/index.d.ts",
|
|
21
|
-
"import": "./dist/websocket/index.js",
|
|
22
|
-
"default": "./dist/websocket/index.js"
|
|
23
18
|
}
|
|
24
19
|
},
|
|
25
20
|
"engines": {
|