aegis-platform-sdk 1.0.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -489,6 +489,30 @@ declare class GeoResource {
489
489
  source_name?: string;
490
490
  }): Promise<T>;
491
491
  deleteZone(zoneId: string): Promise<void>;
492
+ /** Builder layers of the tenant, grouped by "map" (the project). */
493
+ layers<T = Json>(): Promise<T>;
494
+ /** Creates a layer (empty inline dataset + published board). The
495
+ * `node_type` derives from the name and is IMMUTABLE. */
496
+ createLayer<T = Json>(input: {
497
+ nome: string;
498
+ mapa?: string;
499
+ descricao?: string;
500
+ }): Promise<T>;
501
+ layerFeatures<T = Json>(boardId: string): Promise<T>;
502
+ /** Saves the drawing as a versioned SNAPSHOT. `geometry` is GeoJSON
503
+ * `[lng,lat]`; `geo_style` travels PER FEATURE (colour/alpha/extrusion). */
504
+ saveLayerFeatures<T = Json>(boardId: string, rows: Json[]): Promise<T>;
505
+ /** Runs the board and RECONCILES — a feature deleted in the builder leaves
506
+ * the map (the engine is upsert-only). */
507
+ publishLayer<T = Json>(boardId: string): Promise<T>;
508
+ /** Renames / regroups. Never changes the `node_type`; `mapa: ""` ungroups. */
509
+ patchLayer<T = Json>(boardId: string, changes: {
510
+ nome?: string;
511
+ mapa?: string;
512
+ descricao?: string;
513
+ }): Promise<T>;
514
+ /** Deletes the whole layer: materialized nodes + dataset + board. */
515
+ deleteLayer<T = Json>(boardId: string): Promise<T>;
492
516
  }
493
517
  /** `client.mapTemplates.*` — reusable map specs (v22).
494
518
  * (The Python SDK's stdout `Map` builder is sandbox-IDE-only and is not ported.) */
@@ -597,6 +621,85 @@ declare class TimeSeriesResource {
597
621
  render<T = Json>(chartId: string): Promise<T>;
598
622
  }
599
623
 
624
+ /**
625
+ * Body do `POST /public/v1/guest/{token}/fix` — uma leitura de GPS do visitante.
626
+ * O backend avalia cerca/rota/destino (evaluate_fix) e devolve
627
+ * inside_fence/arrived/deviated. Sem throttle e sem geofence-gate nesta rota.
628
+ */
629
+ interface GuestFix {
630
+ lat: number;
631
+ lng: number;
632
+ accuracy?: number;
633
+ /** ISO-8601; o backend usa "agora" se ausente. */
634
+ ts?: string;
635
+ /** Veredito de desvio do PRÓPRIO cliente (ex.: livetracker checando contra a
636
+ * rota desenhada por ruas). O backend RELAIA à portaria (paridade legado);
637
+ * ausente ⇒ o backend calcula pelo desvio da reta do token. */
638
+ off_route?: boolean;
639
+ }
640
+ /** Body do `POST /{token}/document/object-sets/query`. */
641
+ interface GuestObjectSetQuery {
642
+ object_type: string;
643
+ filter?: Json;
644
+ order_by?: Json;
645
+ /** 1..10000, default 200 no backend. */
646
+ limit?: number;
647
+ }
648
+ /**
649
+ * O transporte + a base URL. `mediaUrl()` precisa da base para montar um
650
+ * `<img src>`; o AegisClient satisfaz isto (implementa Transport e expõe
651
+ * `readonly baseUrl`).
652
+ */
653
+ interface PublicGuestTransport extends Transport {
654
+ readonly baseUrl: string;
655
+ }
656
+ /**
657
+ * `client.publicGuest.*` — o lado CONSUMIDOR do guest token público
658
+ * (`/public/v1/guest/{token}/*`). Sem cookie e sem Authorization: o token
659
+ * viaja no path; construa um client anônimo (`new AegisClient({ baseUrl })`).
660
+ *
661
+ * Erros mapeados pelo transporte: 404 (token inválido/expirado/revogado —
662
+ * "never leaks why"), 403 (geofence-gate/ação não permitida — invoke),
663
+ * 429 (throttle — invoke). Visita finalizada (chegou ao destino) → 410, que
664
+ * cai em `AegisAPIError` com `statusCode === 410`.
665
+ */
666
+ declare class PublicGuestResource {
667
+ private readonly t;
668
+ constructor(t: PublicGuestTransport);
669
+ private base;
670
+ /** Menu/resumo do token: label, subject, status, geo, ações permitidas. */
671
+ menu<T = Json>(token: string): Promise<T>;
672
+ /** Reporta uma posição GPS; o backend avalia cerca/rota/destino. */
673
+ fix<T = Json>(token: string, body: GuestFix): Promise<T>;
674
+ /** Invoca uma ação permitida do token (ex.: abrir portão). */
675
+ invoke<T = Json>(token: string, actionId: string, input?: Json): Promise<T>;
676
+ /**
677
+ * Onda 2 — última posição do VISITANTE amarrado a um token de MORADOR
678
+ * (`geo.live_ref`). Sem push: a SPA do morador faz polling desta rota. O
679
+ * morador só vê ESSA visita (least-privilege). Retorna `{available, lat,
680
+ * lng, ts, inside_fence, arrived, deviated, distance_to_target_m,
681
+ * visit_status}`; `available:false` enquanto o visitante não mandou fix.
682
+ */
683
+ position<T = Json>(token: string): Promise<T>;
684
+ /** Documento vinculado ao token (se `geo.document_id`). */
685
+ document<T = Json>(token: string): Promise<T>;
686
+ /** Consulta um object-set embutido no documento do token. */
687
+ queryObjectSet<T = Json>(token: string, body: GuestObjectSetQuery): Promise<T>;
688
+ /** Um nó da ontologia referenciado pelo documento (mascarado por ABAC). */
689
+ documentNode<T = Json>(token: string, nodeId: string): Promise<T>;
690
+ /** Descritor da Page vinculada ao token (`geo.page_slug`). */
691
+ page<T = Json>(token: string, slug: string): Promise<T>;
692
+ /** Avalia as variáveis da Page (com overrides só de variáveis estáticas). */
693
+ evaluatePage<T = Json>(token: string, slug: string, overrides?: Json): Promise<T>;
694
+ /**
695
+ * URL absoluta de um objeto de mídia do documento (bytes servidos com
696
+ * `Cache-Control: private`). Retorna string p/ `<img src>`/`<a href>` —
697
+ * NÃO faz request (o transporte é JSON-cêntrico). A `key` deve começar
698
+ * com `notepad/{doc_id}/` (validado no backend).
699
+ */
700
+ mediaUrl(token: string, key: string): string;
701
+ }
702
+
600
703
  declare class AlertFeedsResource {
601
704
  private readonly t;
602
705
  constructor(t: Transport);
@@ -683,6 +786,38 @@ declare class AlertsResource {
683
786
  constructor(t: Transport);
684
787
  escalate(alertId: string): Promise<void>;
685
788
  channels<T = Json>(): Promise<T[]>;
789
+ /**
790
+ * `PUT /alerts/channels/{ref}` — point a delivery channel at its
791
+ * destination.
792
+ *
793
+ * Exists so this is a GESTURE: before it, sending alerts to the team's
794
+ * Discord (or any webhook) meant editing the tenant's JSONB in the
795
+ * database. Audited as `alert_channel.configured`.
796
+ *
797
+ * `ref` is the channel name (`"discord"`) or a named ref
798
+ * (`"discord-plantao"`, then pass `channel: "discord"`). Fields are open
799
+ * because the vocabulary belongs to the CHANNEL, not the core.
800
+ *
801
+ * The response returns the config MASKED — a webhook URL is the
802
+ * credential, and reads never hand it back whole.
803
+ * Perm: `alerts.routes.manage`.
804
+ */
805
+ setChannel<T = Json>(ref: string, config: AlertChannelConfigInput): Promise<T>;
806
+ /** `DELETE /alerts/channels/{ref}` — audited as `alert_channel.removed`. */
807
+ deleteChannel(ref: string): Promise<void>;
808
+ }
809
+ /** What `setChannel` accepts. Open-ended on purpose: the vocabulary is the
810
+ * channel's, not the core's. */
811
+ interface AlertChannelConfigInput {
812
+ /** Which channel a named ref belongs to (omit when ref === channel). */
813
+ channel?: string;
814
+ /** Webhook address. This IS the credential — reads return it masked. */
815
+ url?: string;
816
+ to?: string;
817
+ token?: string;
818
+ username?: string;
819
+ allowlist?: string[];
820
+ timeout?: number;
686
821
  }
687
822
  /** `client.alarms.*` — threshold alarm rules on node properties (v26). */
688
823
  declare class AlarmsResource {
@@ -726,6 +861,43 @@ declare class EventsResource {
726
861
  all?: boolean;
727
862
  }): Promise<T>;
728
863
  }
864
+ /**
865
+ * Pairing state for a skill that declares the `pairing` capability (e.g. a
866
+ * WhatsApp station). `qr_data_url` is a ready-to-render `data:image/png;base64`.
867
+ */
868
+ interface PairingInfo {
869
+ state: "connected" | "awaiting_scan" | "disconnected" | "error";
870
+ qr_data_url: string | null;
871
+ code: string | null;
872
+ expires_at: string | null;
873
+ detail: string;
874
+ /** Additive (pool station): WHICH number is pairing — single-instance skills never set it. */
875
+ pairing_number?: string | null;
876
+ }
877
+ /**
878
+ * Result of an inventory gesture on a skill that declares the `inventory`
879
+ * capability. `detail` carries the driver's own sentence ("já existe número
880
+ * com este identificador") — it is the operator's diagnosis, so surface it
881
+ * instead of a generic failure.
882
+ */
883
+ interface InventoryResult {
884
+ ok: boolean;
885
+ detail: string;
886
+ item?: Record<string, unknown> | null;
887
+ }
888
+ /** A row of the connector skill catalog (`GET /governance/agents/skills`). */
889
+ interface SkillCatalogRow {
890
+ skill_key: string;
891
+ label: string;
892
+ description: string;
893
+ category: string;
894
+ source: string;
895
+ platforms: string[];
896
+ requires_secrets: string[];
897
+ param_schema: Json[];
898
+ /** Additive — declared capabilities of the skill, e.g. `["pairing"]`. */
899
+ capabilities?: string[];
900
+ }
729
901
  /** `client.connectors.*` — HTTP connector agents under governance. */
730
902
  declare class ConnectorsResource {
731
903
  private readonly t;
@@ -751,9 +923,31 @@ declare class ConnectorsResource {
751
923
  }): Promise<Json>;
752
924
  test<T = Json>(agentId: string): Promise<T>;
753
925
  run<T = Json>(agentId: string): Promise<T>;
926
+ /**
927
+ * Start/renew QR pairing for a skill with the `pairing` capability (WhatsApp
928
+ * station). Pass `{ refresh: true }` to force a fresh code.
929
+ */
930
+ pairingStart<T = PairingInfo>(agentId: string, skillKey: string, opts?: {
931
+ refresh?: boolean;
932
+ target?: string;
933
+ }): Promise<T>;
934
+ /** Read-only poll of the pairing state (no side effects). `target` aims a pool number. */
935
+ pairingPoll<T = PairingInfo>(agentId: string, skillKey: string, opts?: {
936
+ target?: string;
937
+ }): Promise<T>;
938
+ /**
939
+ * Add / correct / remove a sub-unit administered by a connector that
940
+ * declares the `inventory` capability — e.g. one number of a WhatsApp
941
+ * number-station.
942
+ *
943
+ * Reading is NOT here: the inventory already reaches callers through the
944
+ * snapshot the tick publishes on the device mirror (`GET /api/v1/edge/nodes`
945
+ * → `nodes[].pool`). A second read path would drift between ticks.
946
+ */
947
+ applyInventory<T = InventoryResult>(agentId: string, skillKey: string, op: "add" | "update" | "remove", item: Record<string, unknown>): Promise<T>;
754
948
  schedulerTick<T = Json>(): Promise<T>;
755
- /** source ∈ native|clawhub */
756
- skillCatalog<T = Json>(source?: string): Promise<T[]>;
949
+ /** source ∈ native|clawhub. Rows carry an additive `capabilities` field. */
950
+ skillCatalog<T = SkillCatalogRow>(source?: string): Promise<T[]>;
757
951
  installOpenclaw<T = Json>(slug: string): Promise<T>;
758
952
  refreshOpenclaw<T = Json>(): Promise<T>;
759
953
  }
@@ -982,6 +1176,12 @@ interface GuestTokenIssue {
982
1176
  min_interval_seconds?: number;
983
1177
  /** `{ fence, target, arrival_radius_m }` */
984
1178
  geo?: Json;
1179
+ /**
1180
+ * Free-form denormalized contact (e.g. `{ phone, document, notes }`),
1181
+ * surfaced by real-time gate screens without extra reads. Multi-domain: the
1182
+ * site decides what goes here.
1183
+ */
1184
+ contact?: Json;
985
1185
  /** `{ channel, to, text? }` */
986
1186
  share?: Json;
987
1187
  link_base?: string;
@@ -1341,14 +1541,113 @@ declare class CctvResource {
1341
1541
  to_ms?: number;
1342
1542
  }): Promise<string>;
1343
1543
  }
1544
+ /**
1545
+ * A number of a pool station's inventory (`GET /api/v1/edge/nodes` →
1546
+ * `nodes[].pool.numbers[]`). Published by the `connector.whatsapp_pool` tick.
1547
+ */
1548
+ interface EdgePoolNumber {
1549
+ id: string;
1550
+ msisdn?: string;
1551
+ role?: string;
1552
+ owner?: string;
1553
+ state?: string;
1554
+ sendable?: boolean;
1555
+ needs_gesture?: boolean;
1556
+ banned_until?: string | null;
1557
+ sent?: number;
1558
+ /** Present only when a device is declared for this number (opt-in). */
1559
+ automation?: EdgePoolAutomation | null;
1560
+ }
1561
+ /**
1562
+ * Android relink automation for one number. The phone is an edge: when a
1563
+ * session dies, a runner types the 8-character pairing code on the declared
1564
+ * device. Absent when no device is declared — the number stays on the manual
1565
+ * gesture and the row is unchanged.
1566
+ */
1567
+ interface EdgePoolAutomation {
1568
+ /** `"idle"` | `"pending"` | `"attempting"` | `"confirming"` | `"needs_human"` */
1569
+ state?: string;
1570
+ attempts?: number;
1571
+ max_attempts?: number;
1572
+ /** Why the automation gave up. Truncated to 160 chars by the backend. */
1573
+ last_error?: string;
1574
+ last_attempt_at?: string;
1575
+ last_success_at?: string;
1576
+ device?: {
1577
+ serial?: string;
1578
+ /** 0 = not reported. */
1579
+ battery?: number;
1580
+ screen_on?: boolean;
1581
+ wa_foreground?: boolean;
1582
+ at?: string;
1583
+ };
1584
+ }
1585
+ /** Pool snapshot of a number-station device (additive `pool` on {@link EdgeNode}). */
1586
+ interface EdgePoolSummary {
1587
+ station?: string | null;
1588
+ state?: string | null;
1589
+ health?: {
1590
+ total?: number;
1591
+ sendable?: number;
1592
+ standby?: number;
1593
+ needs_gesture?: number;
1594
+ temp_banned?: number;
1595
+ connected?: boolean;
1596
+ };
1597
+ numbers?: EdgePoolNumber[];
1598
+ }
1599
+ /**
1600
+ * An edge device row from `GET /api/v1/edge/nodes`. `kind` is additive —
1601
+ * `"camera_gateway"` | `"whatsapp_station"` | `"whatsapp_pool"` |
1602
+ * `"autosync_bridge"` (absent = legacy camera gateway). `pool` is additive —
1603
+ * present only on number-station devices whose connector published inventory.
1604
+ */
1605
+ interface EdgeNode {
1606
+ edge_id: string;
1607
+ name: string;
1608
+ kind?: string;
1609
+ status: string;
1610
+ version: string;
1611
+ last_seen_at: string | null;
1612
+ update_available: boolean;
1613
+ cameras_ok: number | null;
1614
+ pool?: EdgePoolSummary | null;
1615
+ /**
1616
+ * Connector behind a station-like device. `capabilities` are the ones the
1617
+ * skill DECLARES (`"pairing"`, `"inventory"`, …) — gate each gesture by
1618
+ * them, never by a hardcoded skill key.
1619
+ */
1620
+ pairing?: {
1621
+ agent_id: string;
1622
+ slug: string;
1623
+ skill_key: string;
1624
+ capabilities?: string[];
1625
+ } | null;
1626
+ }
1344
1627
  /** `client.edge.*` — edge node pairing + fleet version pinning. */
1345
1628
  declare class EdgeResource {
1346
1629
  private readonly t;
1347
1630
  constructor(t: Transport);
1631
+ /**
1632
+ * Issue a single-use pairing code (short TTL). The plaintext `code` appears
1633
+ * ONLY in this response (hash at rest).
1634
+ *
1635
+ * `grants` GRANTS gestures to whichever device redeems the code (allowlist;
1636
+ * today `["retry"]`, so a desk app can ask the station to reconnect a
1637
+ * number). Empty — the default — is **read only**: least privilege, and
1638
+ * granting has to be a choice. The grant travels from the code to the node
1639
+ * and dies with it on `revoke`.
1640
+ *
1641
+ * Even when granted, the device never receives the gesture's ADDRESS
1642
+ * (`agent_id`/`skill_key`): it sends the verb and the server routes it.
1643
+ * Perm: `connectors.manage`.
1644
+ */
1348
1645
  createPairingCode<T = Json>(opts?: {
1349
1646
  label?: string;
1350
1647
  ttl_seconds?: number;
1648
+ grants?: string[];
1351
1649
  }): Promise<T>;
1650
+ /** Nodes carry an additive `kind` field — see {@link EdgeNode}. */
1352
1651
  listNodes<T = Json>(): Promise<T>;
1353
1652
  listDiscovered<T = Json>(): Promise<T[]>;
1354
1653
  revoke<T = Json>(edgeId: string): Promise<T>;
@@ -2189,6 +2488,8 @@ declare class AegisClient implements Transport {
2189
2488
  readonly pages: PagesResource;
2190
2489
  readonly dossier: DossierResource;
2191
2490
  readonly timeseries: TimeSeriesResource;
2491
+ /** Public guest-token consumer surface (`/public/v1/guest/{token}/*`). */
2492
+ readonly publicGuest: PublicGuestResource;
2192
2493
  readonly alerts: AlertsResource;
2193
2494
  readonly alarms: AlarmsResource;
2194
2495
  readonly events: EventsResource;
@@ -2369,4 +2670,4 @@ interface OSDKClient {
2369
2670
  }
2370
2671
  declare function asOsdkClient(client: AegisClient): OSDKClient;
2371
2672
 
2372
- export { ALL_PERMISSIONS, APPLICATIONS, AccessAuditResource, AegisAPIError, AegisClient, type AegisClientOptions, AipResource, AlarmsResource, AlertsResource, AppShellResource, AtlasResource, AuthError, AuthResource, BriefingResource, CAPABILITY_PERMISSIONS, CLASSIFICATION_LABEL, CLASSIFICATION_RANK, CampaignResource, type CapabilityPermissionKey, CctvResource, ChatResource, ClassificationInvariantViolation, type ClassificationLevel, CodeRepositoriesResource, CodegenResource, ComputeControlResource, ComputeResource, ComunicadosResource, ConnectorsResource, CorrelationResource, DatasetsResource, type DevMode, DocsResource, DossierResource, EdgeResource, ErasureResource, type ErasureSelector, EventsResource, FormsResource, type FunctionCreate, FunctionsResource, GeoResource, GroupsResource, type GuestTokenIssue, GuestTokensResource, type IamPermissionDef, IamResource, InferenceResource, type Json, LineageResource, type LoginOptions, MapTemplatesResource, MarketplaceResource, MarkingsResource, MediaResource, MergeResource, type MergeTarget, NAV_PERMISSIONS, type NavPermissionKey, NotFoundError, NotepadResource, type OSDKClient, type ObjectTypeWrite, OntologyResource, OperatorResource, type OperatorTaskCreate, type OperatorTaskListOptions, OrganizationsResource, type OsdkApplication, OsdkResource, type OsdkToken, type OsdkTokenWithSecret, PagesResource, type Permission, PermissionDeniedError, type PermissionKey, PipelinesResource, PlatformV22Resource, PlatformV23Resource, PlatformV24Resource, PlatformV25Resource, PlatformV26Resource, ProjectsResource, PropertyMarkingsResource, type PullRequestCreate, type QueryParams, type RequestOptions, ResourceMarkingsResource, RetentionResource, type RetryOptions, type Role, RowPoliciesResource, SituationalResource, SolutionsResource, SpacesResource, type SseEvent, type Tenant, TimeSeriesResource, type TokenPair, type TransactionKind, type Transport, type User, VALID_LEVELS, VALID_PROJECT_ROLES, VideoResource, type WhoAmI, WorkshopResource, WorkspaceUpdatesResource, WorkspacesResource, applicationBySlug, applicationHas, asOsdkClient, isSystemPermission, listApplications, listPermissions, maxLevel, parseSseStream, validateApplication, validateInvariant };
2673
+ export { ALL_PERMISSIONS, APPLICATIONS, AccessAuditResource, AegisAPIError, AegisClient, type AegisClientOptions, AipResource, AlarmsResource, type AlertChannelConfigInput, AlertsResource, AppShellResource, AtlasResource, AuthError, AuthResource, BriefingResource, CAPABILITY_PERMISSIONS, CLASSIFICATION_LABEL, CLASSIFICATION_RANK, CampaignResource, type CapabilityPermissionKey, CctvResource, ChatResource, ClassificationInvariantViolation, type ClassificationLevel, CodeRepositoriesResource, CodegenResource, ComputeControlResource, ComputeResource, ComunicadosResource, ConnectorsResource, CorrelationResource, DatasetsResource, type DevMode, DocsResource, DossierResource, type EdgeNode, type EdgePoolAutomation, type EdgePoolNumber, type EdgePoolSummary, EdgeResource, ErasureResource, type ErasureSelector, EventsResource, FormsResource, type FunctionCreate, FunctionsResource, GeoResource, GroupsResource, type GuestFix, type GuestObjectSetQuery, type GuestTokenIssue, GuestTokensResource, type IamPermissionDef, IamResource, InferenceResource, type InventoryResult, type Json, LineageResource, type LoginOptions, MapTemplatesResource, MarketplaceResource, MarkingsResource, MediaResource, MergeResource, type MergeTarget, NAV_PERMISSIONS, type NavPermissionKey, NotFoundError, NotepadResource, type OSDKClient, type ObjectTypeWrite, OntologyResource, OperatorResource, type OperatorTaskCreate, type OperatorTaskListOptions, OrganizationsResource, type OsdkApplication, OsdkResource, type OsdkToken, type OsdkTokenWithSecret, PagesResource, type PairingInfo, type Permission, PermissionDeniedError, type PermissionKey, PipelinesResource, PlatformV22Resource, PlatformV23Resource, PlatformV24Resource, PlatformV25Resource, PlatformV26Resource, ProjectsResource, PropertyMarkingsResource, PublicGuestResource, type PublicGuestTransport, type PullRequestCreate, type QueryParams, type RequestOptions, ResourceMarkingsResource, RetentionResource, type RetryOptions, type Role, RowPoliciesResource, SituationalResource, type SkillCatalogRow, SolutionsResource, SpacesResource, type SseEvent, type Tenant, TimeSeriesResource, type TokenPair, type TransactionKind, type Transport, type User, VALID_LEVELS, VALID_PROJECT_ROLES, VideoResource, type WhoAmI, WorkshopResource, WorkspaceUpdatesResource, WorkspacesResource, applicationBySlug, applicationHas, asOsdkClient, isSystemPermission, listApplications, listPermissions, maxLevel, parseSseStream, validateApplication, validateInvariant };