@collective-intelligence/external-apps-server-sdk 0.1.4 → 0.1.5
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/README.md +63 -5
- package/dist/admin.d.ts +12 -0
- package/dist/gateway.js +1 -1
- package/dist/index.d.ts +124 -0
- package/dist/index.js +1 -1
- package/dist/persistence/drizzle.js +1 -1
- package/dist/runtime/effect.js +1 -1
- package/dist/tools/ai-sdk.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -427,6 +427,54 @@ succeeded before the new turn started count. A turn is
|
|
|
427
427
|
subject, never with the application's scopes. Visitors are separate owners:
|
|
428
428
|
one visitor never reads another visitor's conversation.
|
|
429
429
|
|
|
430
|
+
## Messages
|
|
431
|
+
|
|
432
|
+
`messages.send` sends one message through a messaging connection of the
|
|
433
|
+
Organization, for example a Telegram bot or a WhatsApp Business Account. The
|
|
434
|
+
application needs the `messaging:send` scope, and an administrator must grant
|
|
435
|
+
the connection to the application on its administration page.
|
|
436
|
+
|
|
437
|
+
```ts
|
|
438
|
+
const sent = await ci.messages.send({
|
|
439
|
+
connectionId,
|
|
440
|
+
content: { kind: "text", text: "Your order is ready." },
|
|
441
|
+
idempotencyKey: `order-${orderId}-ready`,
|
|
442
|
+
organizationId,
|
|
443
|
+
target: { conversation, mode: "continue" }
|
|
444
|
+
})
|
|
445
|
+
// sent.value.result: { conversation, messageId }
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
- `target` continues a conversation with the Conversation Reference of an
|
|
449
|
+
earlier message (`{ mode: "continue", conversation }`), or starts one with
|
|
450
|
+
the recipient fields of the vendor (`{ mode: "start_new", recipient }`).
|
|
451
|
+
- `content` is a text, or `{ kind: "voice", text, voice }` for a text that CI
|
|
452
|
+
speaks.
|
|
453
|
+
- `sender` holds the sender fields of the vendor, for example
|
|
454
|
+
`{ phoneNumberId }`. It is required when the account has more than one
|
|
455
|
+
sender. `service` names the vendor service when the connection has more
|
|
456
|
+
than one.
|
|
457
|
+
- The result is the Message Receipt: the message id of the vendor and the
|
|
458
|
+
Conversation Reference that continues the conversation. It means that the
|
|
459
|
+
vendor accepted the message, not that a person received it.
|
|
460
|
+
- `idempotencyKey` (at most 256 characters; generated when omitted) makes a
|
|
461
|
+
repeat safe. A repeat with the same key and content returns the first
|
|
462
|
+
outcome and sends nothing. A repeat with the same key and other content
|
|
463
|
+
returns `conflict`. Use your own key when your server can repeat a send
|
|
464
|
+
after a crash.
|
|
465
|
+
- CI sends once and never retries a failed send. A failed send returns
|
|
466
|
+
`message_send_failed` with a `sendErrorCode`, for example `window_closed`,
|
|
467
|
+
`recipient_unreachable`, `template_required` or `transport`. The same key
|
|
468
|
+
returns the same failure: use a new key to send again.
|
|
469
|
+
- `send_outcome_unknown` means that the first send with the key has no
|
|
470
|
+
recorded outcome: it still runs, or CI stopped before it recorded the
|
|
471
|
+
outcome. CI does not send again for the key. Repeat the call later; if the
|
|
472
|
+
answer stays the same, check with the vendor before you send with a new key.
|
|
473
|
+
- `not_found` means that the connection does not exist or is not granted to
|
|
474
|
+
the application. `rate_limited` (HTTP 429) means that the connection
|
|
475
|
+
reached its rate limit; it is retryable, and the client repeats it with the
|
|
476
|
+
same key.
|
|
477
|
+
|
|
430
478
|
## Member users
|
|
431
479
|
|
|
432
480
|
A confidential application administers the `member` users of its own
|
|
@@ -503,11 +551,18 @@ const links = await ci.users.listCompanyLinks({ organizationId, userId })
|
|
|
503
551
|
- A delegated user's `/application/v1/resources` and `knowledge_*` calls, and
|
|
504
552
|
the Agents, Skills and workflows the user runs, carry the user's links to
|
|
505
553
|
Knowledge policy as `subject.linkedCompanyIds`, and a policy reads the
|
|
506
|
-
entity id as `resource` path `["id"]`.
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
554
|
+
entity id as `resource` path `["id"]`. CI also sets `subject.access`:
|
|
555
|
+
`"read"` for gets, lists, searches, facets, autocomplete, traversal and
|
|
556
|
+
retrieval, `"write"` for creates, updates, deletes and relation writes. The
|
|
557
|
+
operation sets it; a caller cannot. A policy that does not test `access`
|
|
558
|
+
applies to reads and writes alike.
|
|
559
|
+
- To let `member`-role users write only their own companies but read every
|
|
560
|
+
company (for example through member-run Agents), declare a `deny` `filter`
|
|
561
|
+
policy on the company schema: subject match `user.role` equals `member` and
|
|
562
|
+
`access` equals `write`, rule "entity id not in `linkedCompanyIds`". Updates
|
|
563
|
+
and deletes of any other company, and creates, then fail with `forbidden`;
|
|
564
|
+
gets, lists and searches still return it. Without the `access` clause the
|
|
565
|
+
same policy also hides other companies from reads. Other roles and service
|
|
511
566
|
credentials are unaffected.
|
|
512
567
|
- The policy binds an execution only while it acts as the member. An Agent or
|
|
513
568
|
Skill tool bound to a fixed user, or a workflow that runs as another user or
|
|
@@ -1159,6 +1214,9 @@ OAuth client may supply `clientSecret`; a public PKCE client omits it.
|
|
|
1159
1214
|
`CI_CLIENT_SECRET`. `readApplicationEnrollment` reads those variables, so the
|
|
1160
1215
|
application names none of them. It throws a `TypeError` that lists every
|
|
1161
1216
|
missing variable. Pass the same prefix as `--prefix` when it is not `CI_`.
|
|
1217
|
+
`ci apps env <application>` prints the same variables for an application that
|
|
1218
|
+
already exists, for example to copy them into a deployment pipeline; it leaves
|
|
1219
|
+
out `CI_CLIENT_SECRET`, which CI shows only once.
|
|
1162
1220
|
|
|
1163
1221
|
```ts
|
|
1164
1222
|
import {
|
package/dist/admin.d.ts
CHANGED
|
@@ -4965,6 +4965,7 @@ declare const createAdministrationApi: (client: Client$1) => {
|
|
|
4965
4965
|
description: string | null;
|
|
4966
4966
|
directChildCount: number;
|
|
4967
4967
|
directMemberCount: number;
|
|
4968
|
+
fqn: string | null;
|
|
4968
4969
|
id: string;
|
|
4969
4970
|
inheritedMembershipImpact: {
|
|
4970
4971
|
descendantGroupCount: number;
|
|
@@ -4973,6 +4974,11 @@ declare const createAdministrationApi: (client: Client$1) => {
|
|
|
4973
4974
|
};
|
|
4974
4975
|
name: string;
|
|
4975
4976
|
organizationId: string;
|
|
4977
|
+
package: {
|
|
4978
|
+
fqn: string;
|
|
4979
|
+
managed: boolean;
|
|
4980
|
+
readonly: boolean;
|
|
4981
|
+
} | null;
|
|
4976
4982
|
parentGroupId: string | null;
|
|
4977
4983
|
parentPath: Array<{
|
|
4978
4984
|
id: string;
|
|
@@ -5001,6 +5007,7 @@ declare const createAdministrationApi: (client: Client$1) => {
|
|
|
5001
5007
|
description: string | null;
|
|
5002
5008
|
directChildCount: number;
|
|
5003
5009
|
directMemberCount: number;
|
|
5010
|
+
fqn: string | null;
|
|
5004
5011
|
id: string;
|
|
5005
5012
|
inheritedMembershipImpact: {
|
|
5006
5013
|
descendantGroupCount: number;
|
|
@@ -5009,6 +5016,11 @@ declare const createAdministrationApi: (client: Client$1) => {
|
|
|
5009
5016
|
};
|
|
5010
5017
|
name: string;
|
|
5011
5018
|
organizationId: string;
|
|
5019
|
+
package: {
|
|
5020
|
+
fqn: string;
|
|
5021
|
+
managed: boolean;
|
|
5022
|
+
readonly: boolean;
|
|
5023
|
+
} | null;
|
|
5012
5024
|
parentGroupId: string | null;
|
|
5013
5025
|
parentPath: Array<{
|
|
5014
5026
|
id: string;
|